<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="简单"
            android:layout_margin="10px" />        <Button
            android:id="@+id/button2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="中等"
            android:layout_margin="10px" />        <Button
            android:id="@+id/button3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="较难"
            android:layout_margin="10px" />
        
    </LinearLayout>试了半天,不知道要怎么设置属性才能让三个按钮在一条线上均匀的分布? 

解决方案 »

  1.   

    1. LinearLayout要有orientation属性;
    2. 3个Button的android:layout_width="fill_parent",这是要闹哪样?
    3. 均匀是吧,layout_width=0dp并且layout_weight都设为一样的值就好了。
      

  2.   

    三个都加上android:layout_weight=1并且把android:layout_width="wrap_content"
      

  3.   


    1.可以每个button外面套一个LinearLayout之类的容器,容器均匀分页,button在容器里居中;
    2.3个button均匀分布,然后为每个button设置layout_marginLeft和layout_marginRight为一样的值就好了。