编程语言
首页 > 编程语言> > java-未知警告图标-Android Studio

java-未知警告图标-Android Studio

作者:互联网

enter image description here

这是我的simple_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white" />
        </shape>
    </item>
    <item android:state_pressed="true">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/darker_gray" />
        </shape>
    </item>
</selector>

警告图标出现背后的原因是什么,我在做什么错?

我正在使用Android Studio v1.4.1.

解决方法:

您应该有一个无状态项:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="false">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white" />
        </shape>
    </item>
    <item android:state_pressed="true">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/darker_gray" />
        </shape>
    </item>

    <item>
        <shape android:shape="rectangle">
            <solid android:color="@android:color/darker_gray" />
        </shape>
    </item>
</selector>

标签:android-studio,android-layout,android-xml,java,android
来源: https://codeday.me/bug/20191027/1946341.html