user11520652
user11520652

Reputation:

How to set background color inside border in android studio?

I am trying to set border for which i have made this border.xml file, as i have used background keyword to set background color, but there is no effect of adding background keyword. Can anyone guide me how can i set background color inside border. Here is my border.xml code:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">  
<corners android:radius="3dp"/>
<padding android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp"/>
<stroke android:width="5dp" android:color="#A5A5A5" android:background="#2B1B1B"/>
</shape>

Upvotes: 0

Views: 1958

Answers (2)

user11520652
user11520652

Reputation:

Remove android:background="#2B1B1B" from 5th line of the code and use this fter third line of your code

<solid android:color="#2B1B1B"/>

Upvotes: 0

Andi Tenroaji Ahmad
Andi Tenroaji Ahmad

Reputation: 370

You just remove android:background="#2B1B1B" in stroke and add attribute solid like this

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">  
<solid android:color="#2B1B1B"
<corners android:radius="3dp"/>
<padding android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp"/>
<stroke android:width="5dp" android:color="#A5A5A5"/>
</shape>

Upvotes: 1

Related Questions