【发布时间】:2021-04-17 11:57:57
【问题描述】:
我在drawable中创建了一个gradient_file.xml
<?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>
我已将其应用于布局中的按钮
<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" />
这是我得到的结果:
颜色应该不同。我已经重建了项目,但颜色在预览和模拟器中都没有改变。
【问题讨论】:
-
不,如您所见,我已经在做您的解决方案正在做的事情,但我没有得到任何结果。按钮颜色不变
-
请分享项目中使用的风格和主题
标签: android