我正在寻找创建自动缩放的 2x2 行的最佳解决方案。到目前为止,我遇到的问题是左图是全尺寸的,而右图被缩小了很多。
图片将是 400x400 像素,并且可能需要在所有设备上显示。
最佳答案
在您的 XML 布局文件中使用 Android TableLayout
。
注意:如果您的表格中的行数可变,则 GridView
将是合适的。
2x2 示例:
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView android:layout_weight="1"
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView android:layout_weight="1"
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView android:layout_weight="1"
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ImageView android:layout_weight="1"
android:id="@+id/imageView4"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
关于java - 自动缩放的 Android 2x2 行图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15738339/