3
我使用形状XML可绘制作为LinearLayout的背景。形状XML可绘制不能被解析成位图XML可绘制
文件:background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="270"
android:endColor="@color/bg_end_blue"
android:startColor="@color/bg_start_blue" />
<corners android:radius="0dp" />
</shape>
然后我读到抖动以及如何改善这种背景的外观(通过本文http://android.amberfog.com/?p=247),因此我创造了这个位图绘制XML:
文件:background_bitmap.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/background"
android:tileMode="repeat" />
并试图将其应用于LinearLayout。但我得到一个:
org.xmlpull.v1.XmlPullParserException: Binary XML file line #5: <bitmap> requires a valid src attribute
你知道我在做什么错吗?提前致谢!!
需要一个有效的src属性。那背景是有效的吗? – 2011-12-19 09:59:57
是的。我使用可绘制的初始形状作为布局的背景,它是正确的。 – 2011-12-19 10:02:06
我在上面的链接中找到了这一行。 '因为Android中的抖动仅适用于可伸缩或平铺图像。为什么?我不知道。如果你知道 - 请写信给我。我会稍后看看平台代码)'。因此请在ImageView中尝试一次以检查其工作与否 – 2011-12-19 10:05:57