【发布时间】:2015-07-19 20:37:20
【问题描述】:
无论设备大小如何,图像视图元素都保持不变。因此,虽然针对 Nexus 6 等较小的屏幕进行了优化,但各种按钮和图像视图的方向或间距在 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" />
图像视图元素是否必须同时调整大小和缩放?
有些类似的问题:
Layout screwed up on bigger screen sizes.
How to evaluate view size to keep same proportion in all devices?
【问题讨论】:
-
你的问题到底是什么,你为什么要改变宽度/高度? ImageView 默认保留其图像的纵横比...
-
我不知道你在说什么,“图像视图只是没有按比例放大”是什么意思?
-
当然有,只要使用 layout_width / layout_height = "match_parent",如果你指定 200dp 那么它的 200dp,如果你使用 match_parent 它们会填满可用空间
-
按钮?什么按钮?我在您的布局文件中没有看到任何按钮
-
那么
有什么问题?它不实用吗?为什么?