Question

Hi I'm covering my ImageView in buttons but while they are so close to each other you cant make out that it is buttons, its just a big red square. I need a quick and easy way to give my buttons borders/edges or something so you can see the different buttons.

Was it helpful?

Solution

Create a Shape in Drawable Resource

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
   <solid android:color="#C0213A" />`<!--Background Color-->`
   <stroke android:width="2dip" android:color="#C0213A"/> `<!--Border-->`
</shape>

In your XML

<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:background="@drawable/your_shape"> `<!--This is your shape created--`>

OTHER TIPS

There is no border for buttons but you can use shape to make a drawable with border then put it as background for the button.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid android:color="@color/red" />

    <stroke
        android:width="1dp"
        android:color="@color/black" />

</shape>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top