0

I have applied gradient along with round on Button

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="0"
        android:centerColor="#F82634"
        android:endColor="#FA3B6F"
        android:startColor="#FA7D6F" />

    <padding
        android:bottom="7dp"
        android:left="7dp"
        android:right="7dp"
        android:top="7dp" />

    <corners android:radius="8dp" />
</shape>


By applying `android:background="@drawable/gradient_button"`

Padding and Corners are shown in xml whereas gradient start and end color not applied. I have also tried backgroundTint = "@null" but still same issue. I have replace Button with MaterialButton same issue occur

But when I use AppCompatButton it works perfectly.

Can someone guide me what am i missing


<Button
        android:id="@+id/applyNowBtn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/gradient_button"
        android:text="Apply Now"
         />
Moeez Atlas
  • 116
  • 2
  • 11
  • The issue is other because I tried the same and it works fine for me. – Mehul Kabaria Jan 27 '22 at 08:03
  • I have the parent theme set as parent="Theme.MaterialComponents.DayNight.DarkActionBar". If i change it to AppCompat theme the buttons work fine but Material Components get messed up – Moeez Atlas Jan 27 '22 at 08:05

1 Answers1

3

There are two ways to accomplish

Change you Button or MaterialButton to AppCompatButton or Use these theme instead

Have a look at this answer

Material Component theme is still under development .Read this article

Taimoor Khan
  • 541
  • 4
  • 20