Reputation: 897
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...
Upvotes: 16
Views: 40471
Reputation: 1
the second must be written two lines down.just put the cursor before the second and the problem is solved.
Upvotes: 0
Reputation: 1829
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>
Upvotes: 1
Reputation: 969
Replace the tag
<solid android:color="@color/orange"></solid>
instead of
<solid android:color="@color/orange"/>
//like wise all tags
Upvotes: 5
Reputation: 2789
Replacing < include layout = "@layout/layout> < /include> with: < include layout = "@layout/layout /> worked fine for me.
Upvotes: 2
Reputation: 897
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" />
Upvotes: 45
Reputation: 2026
all Android XML layout files need to start with the line:
<?xml version="1.0" encoding="utf-8"?>
so your file should look like:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="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" />
</shape>
Upvotes: 0