Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML has empty body?

Tags:

android

xml

I am new to working with XML and am editing a layout in my Android app and it is giving me the error "XML has empty body" is anyone able to tell me what I have done wrong? This is my code:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/orange"></solid>


<stroke
    android:width="2dp"
    android:color="@color/orange"></stroke>

<padding
    android:bottom="10dp"
    android:left="15dp"
    android:right="15dp"
    android:top="15dp"></padding>

<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="0dp"
    android:radius="1dp"
    android:topLeftRadius="12dp"
    android:topRightRadius="12dp" />

Thanks

Edit: had to add spaces to make first 2 lines appear...

like image 263
juliet Avatar asked May 20 '14 21:05

juliet


4 Answers

It appears to have worked by getting rid of the closing tags and replacing them with the self closing tags:

<solid android:color="@color/orange" />


<stroke
    android:width="2dp"
    android:color="@color/orange" />

<padding
    android:bottom="10dp"
    android:left="15dp"
    android:right="15dp"
    android:top="15dp" />

<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="0dp"
    android:radius="1dp"
    android:topLeftRadius="12dp"
    android:topRightRadius="12dp" />

like image 71
juliet Avatar answered Nov 12 '22 20:11

juliet


Replace the tag

<solid android:color="@color/orange"></solid>

instead of

<solid android:color="@color/orange"/>

//like wise all tags

like image 20
Mani Avatar answered Nov 12 '22 20:11

Mani


Replacing < include layout = "@layout/layout> < /include> with: < include layout = "@layout/layout /> worked fine for me.

like image 2
Red M Avatar answered Nov 12 '22 19:11

Red M


Just place the closing tag on a new line, for example replace:

<solid android:color="@android:color/white"></solid>

with:

<solid android:color="@android:color/white">
</solid>
like image 1
Brainnovo Avatar answered Nov 12 '22 18:11

Brainnovo