我有两个按钮彼此相邻.我希望它们的大小相同,并填满整个屏幕宽度.我一直在试用这段代码:(这是相对布局,如果重要的话)
<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>
Run Code Online (Sandbox Code Playgroud)
Her*_*ter 25
在按钮周围包裹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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19217 次 |
最近记录: |