Android - 复选框文本显示在预览中但不在设备上

时间:2015-01-25 17:48:58

标签: android checkbox android-studio

这是我的复选框,我在预览窗格中正确看到它。

<CheckBox
        android:id="@+id/cbCheck"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:button="@drawable/custom_checkbox"
        android:checked="false"
        android:padding="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:text="@string/will_wait"
        android:layout_alignTop="@+id/txtLeave"
        android:layout_alignBottom="@+id/txtLeave"
        android:layout_toEndOf="@+id/txtLeave"
        android:layout_toRightOf="@+id/txtLeave" />

custom_checkbox是这样的:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:drawable="@drawable/custom_checkbox_checked"/>
    <item android:state_checked="false" android:drawable="@drawable/custom_checkbox_unchecked"/>
</selector>

检查:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient android:startColor="#ffffffff" android:endColor="#0000ff" android:angle="270"/>
    <stroke android:width="4px" android:color="#90caf9" />
    <size android:height="20dp" android:width="20dp"/>
</shape>

未选中:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient android:startColor="#ffffffff" android:endColor="#ffffffff" android:angle="270"/>
    <stroke android:width="4px" android:color="#90caf9" />
    <size android:height="20dp" android:width="20dp"/>
</shape>

虽然我在预览中看到了正确的内容: enter image description here

在我的设备上文字消失了。当我点击“空”空格时,复选框会正确更改状态,但文本不存在。我认为这是一个着色问题,但我只触摸按钮,而不是文本。

0 个答案:

没有答案
相关问题