1

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.

1
  • There we go, found it (pasted wrong one!) Commented Jul 7, 2014 at 1:01

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

3 Comments

This is correct. However, I'm not sure about what @KarlMorrison is trying to do... Do you really want a layer list with only one item? Or was it just a minimum example to reproduce the issue?
@matiash It was a minimum example exactly!
So does that answer your question? Your drawable is present but it is not a valid Bitmap src.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.