【发布时间】:2018-03-19 21:52:14
【问题描述】:
我正在尝试拉伸 300x300 图像以填充父级作为示例布局的背景。然而,它似乎最多可以达到它的最大尺寸作为一个完美的正方形。这是我的代码。
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/app_background"
android:scaleType="fitCenter"
android:adjustViewBounds="true"/>
应用的顶部和底部仍然有空白,我想消除它。任何和所有解决这个困境的办法都将不胜感激。enter image description here
【问题讨论】:
-
为什么不将父母的
android:background设置为@drawable/app_background? 编辑:正如@Chisko 建议的那样,您也可以在ImageView中使用android:scaleType="fitXY" -
玩弄
android:scaleType,fitCenter当前选项负责“完美”的事情 -
天哪,谢谢斯特凡·戈卢博维奇!如果没有你的帮助,我永远不会知道这件事。
标签: android xml imageview fill-parent