Android - 定义彼此相邻的两个按钮

时间:2016-05-01 13:22:22

标签: android xml button

我想用xml以这种方式定义两个按钮,它们彼此相邻: https://i.imgsafe.org/8d60c62.png

  • 我怎么能这样做?感谢。

2 个答案:

答案 0 :(得分:1)

创建线性布局并将方向设置为水平,然后创建按钮

答案 1 :(得分:0)

这样的事情:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
>

<Button
android:layout_width="0"
android:text="button1"
android:layout_height="wrap_content"
android:layout_weight="1"/>


<Button
android:layout_width="0"
android:text="button2"
android:layout_height="wrap_content"
android:layout_weight="1"/>

/LinearLayout>