Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shape XML Drawable cannot be parsed into Bitmap XML Drawable

I am using a shape XML drawable as a background of a LinearLayout.

File: 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>

Then I read about dithering and how this can improve the look of this background (via this article http://android.amberfog.com/?p=247), thus I created this bitmap XML drawable:

File: 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" />

And tried it to apply to the LinearLayout. But I get a:

org.xmlpull.v1.XmlPullParserException: Binary XML file line #5: <bitmap> requires a valid src attribute

Do you know what I am doing wrong? Thanks in advance!!

like image 211
Dimitris Makris Avatar asked Apr 09 '26 19:04

Dimitris Makris


1 Answers

The problem is that you are trying to load a drawable xml file as a bitmap in the background_bitmap.xml. needs an image as its src, another xml file won't work as far as I know.
There have been previous questions about applying dither to gradients, here is one: Is it possible to dither a gradient drawable?

like image 65
Jave Avatar answered Apr 12 '26 09:04

Jave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!