I am trying to create button with backgroundTint to gradient.
I defined my gradient inside drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerX="50%"
android:centerY="50%"
android:endColor="#308c35"
android:gradientRadius="100dp"
android:startColor="#66BB6A"
android:type="linear" />
<corners android:radius="22dp" />
</shape>
Now I am trying to use it as a value to my button:
<com.google.android.material.button.MaterialButton
android:id="@+id/material_unelevated_button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="160dp"
android:layout_height="58dp"
android:layout_marginBottom="84dp"
android:text="@string/button_start_text"
app:backgroundTint="@drawable/main_gradient"
app:cornerRadius="14dp"
app:iconPadding="3dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:strokeWidth="0dp" />
Unfortunately it doesn't work with backgroundTint. I am using material themes, so only changing backgroundTint value I can change how the button looks like. I cannot find solution for this, I tried setting android:background and every other background related option to gradient but it had no effect.