Android CheckBox state_checked自定义可绘制对象未正确显示

问题描述

您好,我为复选框使用了自定义可绘制对象。未检查的可绘制的示出了用于检查的状态很好,而且其它可绘也适当地示出,但是当检查状态为真这可绘制未正确显示

此可绘制对象存在问题,因为未正确显示为复选框可绘制对象。但是,如果我在imageview中使用该drawable,它将显示为正常状态。

这是我状态检查为true的可绘制源xml:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">

<path
    android:fillColor="#293133"
    android:fillType="evenOdd"
    android:pathData="M4 3h16c0.552 0 1 0.448 1 1v16c0 0.552-0.448 1-1 1H4c-0.552 0-1-0.448-1-1V4c0-0.552 0.448 -1 1-1z" />
<path
    android:fillColor="#7ADE4A"
    android:fillType="evenOdd"
    android:pathData="M11.003 16L6.76 11.757 8.174 10.343 11.003 13.172 16.659 7.515 18.074 8.929z" 
 />
</vector>

这是我的可绘制按钮选择器xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

   <item android:drawable="@drawable/icon_check_Box_checked_2"

      android:state_checked="true" />

   <item android:drawable="@drawable/icon_check_Box_unchecked"

      android:state_checked="false" />

</selector>

这是我的复选框:

   <CheckBox
        android:id="@+id/chkAgreement"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:button="@drawable/check_Box_button"
        android:fontFamily="@font/worksansregular"
        android:textColor="@color/text_black_main"
        android:textSize="14sp"
        android:paddingStart="10dp"
        android:text="@string/register_registration_agreement_text"
        tools:ignore="RtlSymmetry" />

复选框选中状态为true可绘制应显示为:

Should show like that

但这是模拟器中的样子,这是什么问题?

real look in emulator

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)