代码之家  ›  专栏  ›  技术社区  ›  metter

安卓:四个正方形的对齐

  •  8
  • metter  · 技术社区  · 16 年前

    方块字

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:id="@+id/MasterLayout" android:layout_width="wrap_content"     android:layout_height="fill_parent"  android:background="#FFFFFF">
    <TableLayout android:layout_width="fill_parent" android:id="@+id/mainlay" android:background="#444444" android:layout_weight="0.2" android:layout_height="wrap_content" android:padding="0dip">
        <TableRow android:layout_weight="1"  android:background="#BBBBBB" android:padding="0dip">
            <ImageView android:id="@+id/ImageView1" android:layout_marginLeft="10px" android:layout_weight="1" android:layout_marginRight="5px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
            <ImageView android:id="@+id/ImageView2" android:layout_marginLeft="5px" android:layout_weight="1" android:layout_marginRight="10px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
        </TableRow>
        <TableRow android:layout_weight="1" android:padding="0dip">
            <ImageView android:id="@+id/ImageView3" android:layout_marginLeft="10px" android:layout_weight="1" android:layout_marginRight="5px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
            <ImageView android:id="@+id/ImageView4" android:layout_marginLeft="5px" android:layout_weight="1" android:layout_marginRight="10px" android:layout_height="wrap_content" android:layout_width="wrap_content" android:scaleType="centerInside" android:src="@drawable/bigbox_new"></ImageView>
        </TableRow>
    </TableLayout>
    </LinearLayout>
    

    基本上就是这样。然而,这四张图片中的每一张上面和下面都有一个巨大的填充物。我该怎么处理呢?或者我需要一起使用不同的布局类型?

    Image

    非常感谢你!

    干杯,马库斯!

    3 回复  |  直到 16 年前
        1
  •  3
  •   molnarm    16 年前

    layout_weight layout_height wrap_content . 然后在它们下面添加一个空表行 布局\u高度 fill_parent .

        2
  •  0
  •   Karan    16 年前

    嗯!

        3
  •  0
  •   Maragues    16 年前

    另外,为什么要在线性布局中放置TableLayout?除非你有更多的元素在线性里面,你可以摆脱它。