Reputation: 9048
I have the following XML drawable to define the different background color for the states of my buttons:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" android:state_selected="true"></item>
<item android:drawable="@android:color/transparent" android:state_pressed="true"></item>
<item android:drawable="@android:color/transparent"></item>
</selector>
How can I add a white border on the right side of my buttons (slightly less in height than the button itself) to act as a divider?
Upvotes: 0
Views: 106
Reputation: 3350
Personally, I add a View in the layout of the Activity or Fragment.
<LinearLayout
android:orientation="horizontal"
android:background="@color/my_button_bar_color"
... >
<Button
... />
<View
android:layout_width="1px"
android:layout_height="20dp"
android:gravity="center_vertical"
android:background="@color/my_button_bar_divider_color" />
<Button
... />
</LinearLayout>
Alternatively, you can create drawables with the border on the right.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/my_border_color" />
</shape>
</item>
<item android:right="1dp">
<solid android:color="@color/my_main_shape_color" />
</item>
</layer-list>
Upvotes: 1