如何解决ImageButton 与暗模式不匹配
我在我的 XML 活动中创建了一个 ImageButton,但它与暗模式不匹配。背景和图像的颜色仍然与正常模式相同。 我正在为这个 ImageButton 和其他 Button 使用一个形状,我在使用 Button 时没有问题。
这是我的代码:
<ImageButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@drawable/roundedbutton"
android:contentDescription="@string/actionButtonDescription"
android:padding="10dp"
android:src="@drawable/ic_baseline_add_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
这里是我的形状“roundedbutton.xml :
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/primaryColor"/>
<corners
android:bottomRightRadius="200dp"
android:bottomLeftRadius="200dp"
android:topRightRadius="200dp"
android:topLeftRadius="200dp"/>
我需要添加一些参数吗?
解决方法
尝试在您的 ImageButton
标记中添加以下行:
android:tint="#0000ffff"
这里的代码 #0000ffff
用于透明颜色。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。