我正在尝试对齐四个相同大小的squares在 Android 屏幕上,我现在已经尝试了一百万种不同的方法,但似乎都不起作用:(。
我目前所掌握的情况如下:
<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 http://www.freeimagehosting.net/uploads/th.a839cd1b5a.png
非常感谢!
干杯,马库斯!
Remove layout_weight
从您的 TableRows 中设置它们layout_height
to wrap_content
。然后在它们下面添加一个空的 TableRowlayout_height
set to fill_parent
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)