basickarl
basickarl

Reputation: 40504

Android XML failed to parse

I have tried restarting eclipse, cleaning, taking away libraries etc. Nothing works! All the files reside in res/drawable

Here is my main layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView android:src="@drawable/language_line" <!-- have also tried android:background, same problem -->
        android:layout_width="200dp"
        android:layout_height="50dp" />

</LinearLayout>

My language_line.xml file:

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

And my language_line_left.xml file:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <gradient 
        android:startColor="#FFFFFFFF" 
        android:endColor="#FF000000"
        android:angle="0" />            
    <size 
        android:width="30dp"
        android:height="5dp" /> 

</shape>

Anyone see anything remotely wrong?

Failed to parse file C:\Programming\workspacev3\Proj\res\drawable\language_line.xml
Exception details are logged in Window > Show View > Error Log

And this:

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

This also only happens when I try and use <bitmap />, otherwise it works just fine. When I CTRL+Space in Eclipse the @drawable/language_line_left pops up, so it is in the resources.

Upvotes: 1

Views: 790

Answers (1)

Jim
Jim

Reputation: 10288

You are trying to reference a drawable that is not a bitmap.

try this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/language_line_left" /> 
</layer-list>

Upvotes: 1

Related Questions