简体   繁体   English

如何调整背景图像的大小以匹配布局?

[英]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.您可以参考CENTER、CENTER_CROP、CENTER_INSIDE、FIT_CENTER、FIT_END、FIT_START、FIT_XY 和 MATRIX 的 android 比例类型。 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但正如您提到的,您可以尝试android:scaleType="center_crop"图像但覆盖整个屏幕

This Should do the trick这应该可以解决问题

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

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

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