【问题标题】:Resize imageViews in a grid layout在网格布局中调整 imageViews 的大小
【发布时间】:2017-03-18 16:38:00
【问题描述】:

我正在尝试在 android 中创建 Tria 游戏。 我创建了一个 3 行 3 列的网格布局。 在单元格内有 9 个方形图像视图。 我想占据网格布局的所有空间,并且图像必须具有相同的尺寸。 我该怎么做?

有布局

<GridLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:columnCount="3"
            android:rowCount="3">

这是一个 imageView 的示例

<ImageView
                android:id="@+id/imageView9"
                android:layout_width="48dip"
                android:layout_height="48dip"
                app:srcCompat="@drawable/android" />

(48dip 用于实验)

【问题讨论】:

    标签: android android-gridlayout


    【解决方案1】:

    根据重量给出固定的宽度和高度,而不是给出

     android:layout_weight="1"
    

    【讨论】:

    • 在哪个代码中? imageView 还是 GridLayout?我没听懂你的回答
    • 父元素和图像视图。
    • android:layout_weight 未在 imageViews 中定义。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-26
    • 1970-01-01
    • 2021-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多