I have created a gradient_file.xml in drawable
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp" />
<gradient
android:startColor="@color/white"
android:endColor="@color/black"
android:angle="45"
android:type="linear" />
</shape>
I have applied it to button in my layout
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="100dp"
android:background="@drawable/gradient_file"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.243" />
This is the result i am getting:
The color should be different. i have rebuild the project but the color does not change in preview nor in emulator.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…