Issue
I have created a xml file called round_button
. It's a simple circular button with a gradient. Here is the simple code
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="3000dip" />
<gradient android:type="linear" android:startColor="#8dbab3" android:endColor="#0DCAAC" />
</shape>
Here is the code of the xml file of my main activity.
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/city"
android:text="Search"
android:background="@drawable/round_button"
/>
why it doen's have the gradient while the shape is correct?
Solution
Everything in your code is okay just change Button to androidx.appcompat.widget.AppCompatButton like below and you will be able to achieve your desire result.
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/city"
android:text="Search"
android:background="@drawable/round_button"
/>
Answered By - Rudra Rokaya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.