Android对齐两个按钮

Android对齐两个按钮,android,alignment,Android,Alignment,我有两个紧挨着的按钮。我希望他们是相同的大小和填补整个屏幕的宽度。我一直在尝试以下代码: (如果有关系的话,这是相对的) 在按钮周围环绕一条线性布局?然后,如果需要,可以使用填充来调整精确位置 <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_

我有两个紧挨着的按钮。我希望他们是相同的大小和填补整个屏幕的宽度。我一直在尝试以下代码: (如果有关系的话,这是相对的)


在按钮周围环绕一条线性布局?然后,如果需要,可以使用填充来调整精确位置

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<Button android:text="Names" 
android:id="@+id/Button01" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button android:text="Dates" 
android:id="@+id/Button02" 
android:layout_toRightOf="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
</LinearLayout>

这是一个漂亮的解决方案。完全按照需要工作。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<Button android:text="Names" 
android:id="@+id/Button01" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
<Button android:text="Dates" 
android:id="@+id/Button02" 
android:layout_toRightOf="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</Button>
</LinearLayout>