Issue
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:
Although the gradient does show in the mini preview, it is not seen anywhere else:
I'm not sure why I'm encountering this problem as I'm following everything by the book.
Cheers, Tom
Solution
Please replace
android:backgroundTint="@drawable/mygrad"
with
android:background="@drawable/mygrad"
Answered By - Emad Seliem
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.