Issue
res/drawable/circle.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#024ee6"
android:endColor="#0292e6"/>
<stroke
android:width="10dip"
android:color="#1161b8" />
<corners android:radius="1000dp" />
<padding
android:bottom="4dp"
android:left="4dp"
android:right="4dp"
android:top="4dp" />
</shape>
In my layout xml there are 2 buttons that use this shape:
<Button
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:drawableTop="@android:drawable/ic_menu_send"
android:background="@drawable/circle"
android:text="btn 1" />
<Button
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:background="@drawable/circle"
android:drawableTop="@android:drawable/ic_menu_manage"
android:text="btn 2" />
Instead of the button's color that should be, the button's color is purple. How can I fix it?
Solution
Your selected color is replaced with purple due to the use of material components in the application theme, so there are two ways to show the color you want
First : add background tint property to button
<Button
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:drawableTop="@android:drawable/ic_menu_send"
android:background="@drawable/circle"
app:backgroundTint="@null" // this line
android:text="btn 1" />
Second : replace Button to AppCompatButton
<androidx.appcompat.widget.AppCompatButton
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:drawableTop="@android:drawable/ic_menu_send"
android:background="@drawable/circle"
android:text="btn 1" />
Answered By - Mr.Droid
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.