Android 在同一布局中并排创建两个按钮?

Android 在同一布局中并排创建两个按钮?,android,Android,我想让两个按钮在同一个布局并排,但我也希望他们粘在一起的布局。。 你可以在下面的链接中看到我的意思 使用水平方向的线性布局 <LinearLayout android:id="@+id/LinearLayout02" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizon

我想让两个按钮在同一个布局并排,但我也希望他们粘在一起的布局。。 你可以在下面的链接中看到我的意思


使用水平方向的线性布局

  <LinearLayout 
        android:id="@+id/LinearLayout02" 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:orientation="horizontal">
        <Button 
            android:id="@+id/Button02" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_weight="1" android:text="Übernehmen">
        </Button>
        <Button 
            android:id="@+id/Button03" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:layout_weight="1" 
            android:text="Abbrechen">
        </Button>
    </LinearLayout>

我希望它对你有用


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="first"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="second"/>
</LinearLayout>
就像我看到你的图像一样。 使用带权重功能的线性布局。 我已经按照您的要求创建了相同的布局。 使用带有选择器的textview按钮

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50sp"
    android:background="#e2e2e2"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/txt_yes"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:background="@drawable/list_selector"
        android:text="YES" />

    <View
        android:layout_width="1sp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="7sp"
        android:layout_marginTop="7sp"
        android:background="@color/BLACK" />

    <TextView
        android:id="@+id/txt_no"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="NO" />
</LinearLayout>

选择器文件txt_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/color_pressed" android:state_pressed="true" /> <!--color_pressed= "#969696" -->
<item android:drawable="@color/txt_color" /> <!--txt_color= "#e2e2e2" -->
</selector>

希望下面的代码对您有用

对于按钮中的分隔符,我使用textview粘贴两个按钮,如图所示

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:weightSum="2">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@android:color/white"
        android:text="YES" />

    <TextView
        android:layout_width="1dp"
        android:layout_height="wrap_content"
        android:background="@color/grey_color" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@android:color/white"
        android:text="NO" />
</LinearLayout>


在此处使用框架布局。“您无法访问该照片”-使用imgur或其他。请解释更多…您的观点不清楚,请解释更多。。。。。。