Java 在按钮之间创建分隔符

Java 在按钮之间创建分隔符,java,android,Java,Android,我在创建按钮分隔符时遇到问题。这是我的按钮布局和我的xml布局我的创建按钮 这是片段活动\u swipe.xml <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Butto

我在创建按钮分隔符时遇到问题。这是我的按钮布局和我的xml布局我的创建按钮

这是
片段活动\u swipe.xml

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/searchDreamButton"

                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button_selector"
                android:gravity="center"
                android:text="@string/search_dream"
                android:textAllCaps="false"
                android:textColor="@color/colorWhite" />

            <Button
                android:id="@+id/singInButton"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_weight="1"
                android:background="@drawable/button_selector"
                android:gravity="center"
                android:text="@string/sign_in"
                android:textAllCaps="false"
                android:textColor="@color/colorWhite" />
        </LinearLayout>

但是试着让这个


试试这个,我的朋友

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:id="@+id/searchDreamButton"

        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@drawable/button_selector"
        android:gravity="center"
        android:text="@string/search_dream"
        android:textAllCaps="false"
        android:textColor="@color/colorWhite" />

    <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:background="#000" />

    <Button
        android:id="@+id/singInButton"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_weight="1"
        android:background="@drawable/button_selector"
        android:gravity="center"
        android:text="@string/sign_in"
        android:textAllCaps="false"
        android:textColor="@color/colorWhite" />
</LinearLayout>

试试这个

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:gravity="center_vertical"
    android:orientation="horizontal"
    android:background="@android:color/holo_blue_bright"
    >

    <Button
        android:id="@+id/searchDreamButton"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center"
        android:background="@android:color/holo_blue_bright"
        android:text="@string/search_dream"
        android:textAllCaps="false"
         />

    <View
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:background="@color/black_color"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        />

    <Button
        android:id="@+id/singInButton"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@android:color/holo_blue_bright"
        android:gravity="center"
        android:text="@string/sign_in"
        android:textAllCaps="false"
        />
</LinearLayout>


只需放置一个宽度为
1
视图
。除了
我的朋友
和所有粗体字之外,这会给公认的答案增加什么?