How do I add a border to a button?

I would like to know how to have a border to separate buttons in my XML file. Can someone please help me?

+3


source to share


2 answers


Use LinearLayout with no children and 1 DP height (assuming you split them vertically)

<Button android:id="@+id/button1" />

<LinearLayout android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="@color/white"/> <!-- Or #FFFFFF -->

<Button android:id="@+id/button2" />

      



You can play with other options, but that should give you a general idea of ​​what (I think) you are looking for. Try to develop and show some sample code for a future question so we can understand your problem and help more!

0


source


<Button android:id="@+id/button1"
 android:layout_marginRight= "2dp" />
<Button android:id="@+id/button2"
 android:layout_marginRight= "2dp" />

      

This installs the 2dp padding on the right side of the button inside the line out.



This is preferred when you are calling another transparent view or a transparent linearlayout, because you get rid of unnecessary layouts with your linelight's built-in layout tools.

0


source







All Articles