0

I am rather new to StackOverFlow - so if you have problems with this question, please tell me in the comments.

I'm creating a basic Android app with a material button with a background set to a gradient drawable like so:

<?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:endColor="#027FEE"
        android:startColor="#2CC6F2" />
</shape>

MainActivity:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
 >

    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:backgroundTint="@drawable/mygrad"
        android:text="Gradient Test"
        android:layout_height="wrap_content"/>
</LinearLayout>

The problem is - this used to work, but I returned to the project 2 days later and the gradient is nowhere to be seen:

enter image description here

Although the gradient does show in the mini preview, it is not seen anywhere else:

enter image description here

I'm not sure why I'm encountering this problem as I'm following everything by the book.

Cheers, Tom

thebluepandabear
  • 263
  • 2
  • 7
  • 29

1 Answers1

0

Please replace

android:backgroundTint="@drawable/mygrad"

with

android:background="@drawable/mygrad"
Emad Seliem
  • 608
  • 1
  • 4
  • 5