Error: <bitmap> requires a valid src attribute

尝试用LayerList来定义背景,定义如下:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
     xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <bitmap 
             android:src="@drawable/background_tile"
             android:tileMode="repeat" />
    </item>
    <item>
            <bitmap android:src="@drawable/background_cover" />
    </item>
</layer-list>

其中background_cover所指向的resource为xml drawable,这将导致application crash,如果换成一般的image drawable则不会出现该问题。

得出结论应该是:<bitmap>的src不允许为xml drawables原因可能是为了避免循环引用(待查)

相关的sites:

http://stackoverflow.com/questions/9788726/using-drawable-resources

http://stackoverflow.com/questions/10055892/preventing-shapes-scaling-in-a-layeredlist-without-using-bitmap

猜你喜欢

转载自michellewang.iteye.com/blog/1717654
今日推荐