java - 自动缩放的 Android 2x2 行图像

标签 java android

我正在寻找创建自动缩放的 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/

相关文章:

java - 用 ImageIcon 刷新 JButton 的方法有哪些?

java - 支柱2 : textbox label is not displayed

android - 导航预览/编辑器未显示

java - 重新启动 ScheduledThreadPoolExecutor 中取消的任务

java - 使用带有 restito 的自定义内容类型模拟 REST 请求

java - Android 中的默认配置菜单

android - 创建一个 JSON 对象数组

android - 如何将抽屉导航图标设置到项目文本的右侧?

Android 库项目无法注册到 Google Map

java - Android - 在 R.id 中定义组