我想在中间的两行和两列有一个页眉和页脚以及四张图片(ImageView)的布局。我不想使用GridView。Android:如何在xml中平衡GridLayout
这就是我所想的:
的网格布局元素走自己的路,大小和不缩水被周围的元素所规定的尺寸。它们要么变得太大,要么脱离页面,要么被以下LinearLayout裁剪掉。这里是我的意思的例子:我想你需要看到XML
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="3" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_gravity="fill_vertical|fill_horizontal"
android:layout_row="0"
android:layout_weight="1"
android:columnCount="2"
android:weightSum="4"
android:rowCount="2" >
<Button
android:id="@+id/button2"
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="fill_vertical|fill_horizontal"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button13"
android:layout_column="1"
android:layout_row="0"
android:layout_gravity="fill_vertical|fill_horizontal"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button14"
android:layout_column="0"
android:layout_row="1"
android:layout_gravity="fill_vertical|fill_horizontal"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="@+id/button15"
android:layout_column="1"
android:layout_row="1"
android:layout_gravity="fill_vertical|fill_horizontal"
android:layout_weight="1"
android:text="Button" />
</GridLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</LinearLayout>
</LinearLayout>
</LinearLayout>
我想:
- 页眉和页脚
- 四个大小相同的图片
- 左右边界在四张图片的周围。
也许我对此采取了错误的做法,所以如有必要请随时以新的方向发送给我。
你的意思是你想在中心没有使用gridview的四个相同大小的图像? – 2014-11-01 04:08:58
是的,没错,没有GridView。 GridView似乎是为图像列表制作的,就像一个相册,它有一个我不想要的动作,当你拖动它时。 – grooble 2014-11-01 04:25:34
然后如果可能的话,把你所有的图像视图放在一个线性布局中,并将重力作为整个布局的中心。 – 2014-11-01 04:31:34