RelativeLayout中两个按钮平分屏幕

<RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <TextView
   android:id="@+id/placeholder"
    android:text=""
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_centerHorizontal="true"/>
  <Button
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_alignRight="@id/placeholder"
    android:layout_alignParentLeft="true"
    android:text="Left"/>
  <Button
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@id/placeholder"
    android:layout_alignParentRight="true"
    android:text="Right"/>
</RelativeLayout>
效果: relativelayout_test 其实就是中间放了一个什么都不显示的textView然后让他定在RelativeLayout的中间(使用layout_centerInParent),剩下的两个一个让他居左一个让他靠右就可以了。
LinearLayout中的android:layout_weight属性的设置和使用 2015-10-02
Java标签的使用 2015-10-04

评论区