如何在Android布局中表示这一点

如何在Android布局中表示这一点,android,tablelayout,Android,Tablelayout,我需要表示以下图表: 每个X将是一个图像按钮。我想制作三张表,每个表有一列,每个单元格的高度为表的一半。问题是桌子需要能够拉伸或收缩,因为我担心屏幕上的所有东西,而桌子是唯一可以改变大小并使整个东西看起来仍然正常的部分。我遇到的问题是,行只有图像按钮那么大。虽然所有图像按钮的大小都相同,但尤其是左表和右表,需要在图像按钮周围添加一些填充,以使其正常工作。我会在按钮上加上边距,但这就解决了我面临的重塑问题……我想。有什么建议吗?如果您使用诸如的UI绘图工具,您可以更轻松地将其组合在一起。完成绘图

我需要表示以下图表:


每个X将是一个图像按钮。我想制作三张表,每个表有一列,每个单元格的高度为表的一半。问题是桌子需要能够拉伸或收缩,因为我担心屏幕上的所有东西,而桌子是唯一可以改变大小并使整个东西看起来仍然正常的部分。我遇到的问题是,行只有图像按钮那么大。虽然所有图像按钮的大小都相同,但尤其是左表和右表,需要在图像按钮周围添加一些填充,以使其正常工作。我会在按钮上加上边距,但这就解决了我面临的重塑问题……我想。有什么建议吗?

如果您使用诸如的UI绘图工具,您可以更轻松地将其组合在一起。完成绘图后,应用程序将生成适用于应用程序的源代码。

如果使用诸如的UI绘图工具,您可能会更轻松地将其组合在一起。完成绘图后,应用程序将生成适用于应用程序的源代码。

尝试使用网格视图

尝试使用网格视图


也许有更好的方法,但下面是实现这一点的一种方法。按钮是否需要拉伸以适应单元格?或者他们只是集中在内部?假设是后者,这里有一个建议(我对此没有信心,但我相信它会起作用):



不幸的是,我现在没有Eclipse来测试这一点,但这应该接近您所需要的。使用RelativeLayout(使用更少的嵌套视图)可能有一种更简洁的方法,但这是我不知道的,给了您一些开始的东西。

可能有更好的方法,但下面是实现这一点的一种方法。按钮是否需要拉伸以适应单元格?或者他们只是集中在内部?假设是后者,这里有一个建议(我对此没有信心,但我相信它会起作用):



不幸的是,我现在没有Eclipse来测试这一点,但这应该接近您所需要的。也许有一种更干净的方法可以使用RelativeLayout(使用更少的嵌套视图),但这是我不知道的,给了你一些开始的东西。

是的,但不要使用绝对布局lululyeah,但不要使用绝对布局lululul这实际上看起来是个不错的主意。我会试试看,然后和你一起回去。ThanksI必须使用RelativeLayout作为子对象来按住图像按钮,而不是线性布局,并在图像按钮上设置align_vertical=true,但这起到了作用。谢谢,谢谢你的后续修复,很高兴它为你解决了!这看起来是个不错的主意。我会试试看,然后和你一起回去。ThanksI必须使用RelativeLayout作为子对象来按住图像按钮,而不是线性布局,并在图像按钮上设置align_vertical=true,但这起到了作用。谢谢,谢谢你的后续修复,很高兴它为你解决了!
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="horizontal"
 >
 <LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:layout_weight="1"
  android:gravity="center"
  >
  <ImageButton
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"                           
   android:layout_weight="1"
   android:src="@drawable/drawable11"
   />
  <ImageButton
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"                           
   android:layout_weight="1"
   android:src="@drawable/drawable12"
   />
 </LinearLayout>

 <LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:layout_weight="1"
  android:gravity="center"
  >
  <ImageButton
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"                           
   android:layout_weight="1"
   android:src="@drawable/drawable21"
   />
  <ImageButton
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"                           
   android:layout_weight="1"
   android:src="@drawable/drawable22"
   />
  <ImageButton
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"                           
   android:layout_weight="1"
   android:src="@drawable/drawable23"
   />
 </LinearLayout>

 <LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:layout_weight="1"
  android:gravity="center"
  >
  <ImageButton
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"                           
   android:layout_weight="1"
   android:src="@drawable/drawable11"
   />
  <ImageButton
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"                           
   android:layout_weight="1"
   android:src="@drawable/drawable12"
   />
 </LinearLayout>
</LinearLayout>