如题所问
需要在一行中排列4个图片按钮,如何让其自动排列达到间距均匀的效果?
用什么layout容器方便?button需要做什么设置

解决方案 »

  1.   

    LinearLayout,每个buttonandroid:layout_width="0px"
    android:layout_weight="1"
      

  2.   

    一般用LinearLayout
    如果想要button均匀排列,一般要用到就是设置它的宽度和权值!
    button里面一般设置:
    android:layout_width
    android:layout_weight=“相同的值”
      

  3.   

      使用LinearLayout <LinearLayout
    android:id="@+id/widget0"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
            android:orientation="horizontal">        <Button android:text="delete" 
    android:id="@+id/Button02" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_marginLeft="20px"
      android:layout_marginRight="20px">
    </Button></LinearLayout>每个button这样设置, 就ok了
      

  4.   

    我觉得  TableLayout方式布局比较好点<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
                  android:layout_width="fill_parent" 
                  android:layout_height="fill_parent" 
                  android:shrinkColumns="0,1,2"><!-- have an eye on ! --> 
        <TableRow><!-- row1 --> 
        <Button android:id="@+id/button1" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"            
                android:text=" Button1" 
                
                /> 
           <Button android:id="@+id/button2" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text=" Button2" 
         android:layout_column="1" 
         /> 
    再填2个
      

  5.   

    用GridView, 网格视图组件, 每一个单元格可以代表一个View对象, 这里可以是Button, 在代码中动态生成所需按钮即可
      

  6.   

    既然还没结贴,那就说下我的方法吧
    使用LinearLayout,每个Button的 layout_weight设为1
    src设为Button的图片背景
    background设为#00000000
    这样各个Button等间距,图片还不会背拉伸
      

  7.   

    方法挺多的,只是使用的一些区别而已,
    LinaerLayout、TableLayout、RelativeLayout等,都可以实现该效果
    看楼主擅长用哪种了