Issue
I have created a rounded button like
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/theme_chocolate_level" />
<corners android:radius="20dp"/>
<padding android:bottom="12dp" android:left="12dp"
android:right="12dp" android:top="12dp"/>
</shape>
I have to use multiple rounded button
but all are in different color. Is there an xml way to use a single generic rounded button for all my buttons. Otherwise I have to create multiple drawable and only change solid color attribute
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_generic_btn"
/>
And I know I can do it programatically but I have a keen interest to do it via xml.
I don't want to do it Programmatically. I know that way
Solution
You can tint you background using backgroundTint attr in your view in xml. Since this attribute was added in API 21 you need to set it with custom prefix.
In your root view: xmlns:app="http://schemas.android.com/apk/res-auto"
and then on view: app:backgroundTint="@color/your_color"
Answered By - Hellboy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.