我background attribute
在android button
. 在该day/light
模式下,该属性可以完美应用而没有问题,但是当切换到 时night/dark mode
,该属性不会被应用,并且会grey background
出现一个按钮而不是theme applied
.
这是我的 android 按钮代码:
<Button
android:id="@+id/logoutbtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/view2"
android:layout_centerHorizontal="true"
android:text="@string/logout_text"
android:textSize="14sp"
android:typeface="normal"
android:layout_marginTop="5dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="20dp"
android:background="@drawable/button_background_accent_rounded"
/>
这是我的背景可绘制代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#2EBAC6"
android:endColor="#4DDCE8"
android:angle="180" />
<corners android:radius="300dp" />
我得到的输出是:
- 白天模式
- 夜间模式
非常感谢任何不更改 java 代码的帮助或建议。