无论设备大小如何, ImageView 元素都保持不变。因此,虽然针对 Nexus 6 等较小的屏幕进行了优化,但各种按钮和 ImageView 的方向或间距并不适合 Nexus 7 等平板设备。
这是因为 layout_width
和 layout_height
属性是专门定义的吗?
对于长宽比,某些问题的答案建议建议使用android:scaleType=fitXY
,但没有产生任何有效的结果。
<ImageView
android:scaleType="fitXY"
android:id="@+id/ring"
android:layout_centerHorizontal="true"
android:layout_marginBottom="58dp"
android:contentDescription="@null"
android:src="@drawable/ring"
android:layout_width="200dp"
android:layout_height="200dp" />
ImageView 元素是否必须同时调整大小和缩放?
有些类似的问题:
Layout screwed up on bigger screen sizes.
How to evaluate view size to keep same proportion in all devices?
最佳答案
您应该使用百分比来表示图像的宽度和高度,如下所示
android1:layout_width="0dip"
android1:layout_height="fill_parent"
android1:layout_weight="0.4885"
关于java - 如何调整 ImageView 元素的位置和大小以利用较大设备上的额外屏幕空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31500885/