Selector, Layer-list and shape/bitmap in the same xml

烈酒焚心 提交于 2019-12-05 04:01:29

This is an error in Android Studio's linting tool. Please file a bug at https://code.google.com/p/android/issues/list.

Also, you can optimize a little by using:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <selector>
            <item android:state_pressed="true">
                <shape android:shape="rectangle">
                    <size android:width="90dp" android:height="90dp" />
                    <solid android:color="#9933CC" />
                </shape>
            </item>
            <item>
                <shape android:shape="rectangle">
                    <size android:width="90dp" android:height="90dp" />
                    <solid android:color="#AA66CC" />
                </shape>
            </item>
        </selector>
    </item>
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/main_achievements_synthesis" />
    </item>
</layer-list>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!