------------------------------------------------------------------------------
|   1   |           |    2   |              |    3      |           |   4   |
|       |           |        |              |           |           |       |
------------------------------------------------------------------------------我想在Layout上主置想同的四个按钮,大小我可以自已指定,控件之间的间隙也可以让我指定该怎么做?我写的XML如下所示,效果却不是我想要的。<TableRow>
<Button
android:id="@+id/1"
android:text="@string/1"
android:layout_height="wrap_content" 
android:layout_width="wrap_content"/>
<Button 
android:id="@+id/2" 
android:layout_height="wrap_content" 
android:text="@string/2" 
android:layout_width="wrap_content"/>
<Button
android:id="@+id/3"
android:layout_height="wrap_content"
android:text="@string/3"
android:layout_width="wrap_content"/>
<Button
android:id="@+id/4"
android:layout_height="wrap_content"
android:text="@string/4"
android:layout_width="wrap_content"/>
</TableRow>
显示出来的效果是这样,请高手们帮帮忙哦。
------------------------------------------------------------------------------
|   1   |  |    2   | |    3                                       |  |    4  |
|       |  |        | |                                            |  |       |
------------------------------------------------------------------------------

解决方案 »

  1.   

    设置你的每个按钮的属性android:layout_weight,让四个按钮值相等,比如都为“1”。这个时候,按钮字体长度一样的话,每个按钮占用空间就是一样的。间距用layout_marging来设置吧
      

  2.   

    你的宽度都是wrap_content,还没有设置比重,不可能出现你说的效果啊,我刚才copy了你的代码在我这没不是你说的效果哦。你可以用楼上的方法把比重都设置为1应该就是你要的效果。还不行的话就把你的整个xml布局发上来。不要只发一点,因为可能是由于其他部分的错误或者父控件导致的呢。
      

  3.   

    的确 7楼说的应该是对的
    你在未设置的时候不可能出现你说的效果
    如果想简单的话Linearlayout和RelativeLayout比较好设置
      

  4.   

    用 tableRow 实现 ,你没有做过网页吗?