Create separator between button

时间:2017-05-16 09:38:38

标签: java android

I have problem with create my button separator. This my buttons layout with my xml layout my create button.

This is fragment activity_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>

enter image description here

but try make separator that this

enter image description here

2 个答案:

答案 0 :(得分:5)

试试这个

<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 :(得分:0)

试试我的朋友

    <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>