Is it possible to specify border in android button?
android, button
Solution
This is not the recommended way to do it because it causes overdraw and adds unnecessary views, Gunaseelan has the proper method.
There's no concept of borders as an attribute. The accepted way is to use a separate drawable as the background to the `View` (using `stroke` as you've mentioned and as @gunaseelan writes).
The other (not recommended) way is to enclose your `Button` in another `View` like a `LinearLayout`, set the background color to the desired border colour on the encapsulating `View` and padding on the outer `View` too.
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#342334"
android:padding="5dp"
>
<Button
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="whatwhaaat"
/>
</LinearLayout>
The value of the padding will indicate the thickness of the border. This method is not recommended as you end up with an extra `View` in your layout, and another layer of overdraw (it draws the `LinearLayout` then the `Button` on top).
Problem
Is it possible to specify border in Android button in the main.xml? [p.s. without the 'separate xml file containing stroke tag' but in the original file where I define the button and also without the 'dynamically by programming' solution and 'images' solution] ``` <Button android:background="#FFFFFF" android:layout_width="0dp" android:layout_height="fill_parent" android:text="Player 3" android:layout_x="0px" android:layout_y="0px" android:id="@+id/p3" android:layout_weight="1" /> ``` here I am changing the background dynamically but the problem is, for 2 buttons there is no border.