Jeremy Jeremy - 2 months ago 6
Android Question

Assigning border attribute to button

I have 4 buttons with across an horizontally-orientated linearlayout which are evenly weighted to split them over a the width of the screen but to improve the appearance, and clearly define the outlines of the buttons, I want to set borders to the buttons but can't figure out how! (I know, this is pathetic!)

I've looked around and can't find the answer - Points for grabs!
Here's the attributes for the button:

<Button
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/dot"
android:id="@+id/dot"
android:layout_width="0dp"
android:background="@color/Button_Color"
android:clickable="true"
android:onClick="SelectDot"/>


Thanks in advance!

Answer

If you just want to space out your buttons, add a layout_margin attribute inside your button definition, such as:

android:layout_margin="10dp"

If you want an actual stroke line around the edge of the button, here is a quick way to create it: http://angrytools.com/android/button/

Just design what you want in there and copy the xml to your file.

Comments