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 用于透明颜色。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...