简体   繁体   English

背景图片未填满布局,并在上方和下方占用了多余的空间

[英]Background image not filling layout and taking extra space above and below

以白卡为背景的线性布局

The blue bordered part is a LinearLayout and the white card part is the background image I have used. 带蓝色边框的部分是LinearLayout而带有白卡的部分是我使用的背景图像。 The background image is not filling the layout. 背景图像未填充布局。

I have tried keeping an ImageView in a FrameLayout and making scale type as centerCrop but even that didn't work. 我试图将ImageView保留在FrameLayout ,并将比例类型设置为centerCrop,但是即使这样也没有用。 I can use a CardView instead but I want this type of shadow as shown in the picture which I couldn't achieve with attributes of CardView . 我可以改用CardView但是我想要这种阴影,如图所示,这是CardView属性无法实现的。

Here is my code: 这是我的代码:

<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@drawable/squared_background_shadow">
</LinearLayout>
  1. Maybe the issue is in the picture you use, it could be png with transparent background? 也许问题出在您使用的图片中,可能是具有透明背景的png?
  2. Which special attributes are you using in LinearLayout , which don't support by CardView ? 您在LinearLayout使用哪些特殊属性, CardView不支持哪些特殊属性?
  3. You can try android:scaleType="fitXY" 您可以尝试android:scaleType="fitXY"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM