【问题标题】:ImageButton doesn't match dark modeImageButton 与暗模式不匹配
【发布时间】:2021-04-20 11:07:15
【问题描述】:

我在我的 XML 活动中创建了一个 ImageButton,但它与暗模式不匹配。背景和图像的颜色仍然与普通模式相同。 我正在为这个 ImageButton 和其他按钮使用一个形状,我对按钮没有任何问题。

这是我的代码:

    <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"/>

我需要添加一些参数吗?

【问题讨论】:

    标签: android xml kotlin imagebutton


    【解决方案1】:

    尝试在 ImageButton 标记中添加以下行:

    android:tint="#0000ffff"  
    

    这里的代码#0000ffff 是透明色。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-23
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多