【发布时间】:2022-01-18 20:25:10
【问题描述】:
我想在我正在使用 Kotlin 开发的 Android 应用中制作渐变按钮。我已经为渐变背景制作了可绘制文件,但是当我为按钮提供自定义背景时,它不起作用,没有任何变化。这是渐变背景的代码,下面是按钮的 XML 代码。
<item>
<shape android:shape="rectangle">
<gradient android:startColor="@color/start_color"
android:endColor="@color/end_color"/>
<corners android:radius="10dp"/>
</shape>
</item>
<com.google.android.material.button.MaterialButton
android:layout_width="match_parent"
android:layout_height="55dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/logo"
android:layout_marginHorizontal="26dp"
tools:layout_editor_absoluteX="16dp"
app:cornerRadius="10dp"
android:textSize="20sp"
android:text="Create an account"
android:background="@drawable/create_acc_btn"
android:fontFamily="@font/montserrat" />
【问题讨论】:
标签: android kotlin button material-design