简体   繁体   中英

How to Resize background image to match the Layout?

我有一个问题,如何在 android studio 中调整背景图像的大小以匹配整个布局,例如:我有一个默认为横向的可绘制对象,但我的布局是水平的,我想减小宽度并增加高度thag 照片以匹配 thr 布局,我该怎么做?

您需要缩放图像,添加此属性并将 fitCenter 更改为与您的条件android:scaleType="fitCenter"对应的值。

Hope this helps. I think you have to add :

android:scaleType="fitXY"
android:adjustViewBounds="true"

But still, check out the link I attached, so you can have a better understanding.

There are android scale types which you can refer CENTER, CENTER_CROP, CENTER_INSIDE, FIT_CENTER, FIT_END, FIT_START, FIT_XY and MATRIX. which can be used as per your requirement. But as you mentioned you can try android:scaleType="center_crop" which crops the image a bit but covers the whole screen

This Should do the trick

android:scaleType="fitXY"
android:adjustViewBounds="true"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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