Does XML have an empty body?

I'm new to working with XML and editing the layout in my Android app and it gives me the error “XML has an empty body”, can anyone tell me what I did 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: I had to add spaces so that the first 2 lines appear ...

+8
android xml
source share
4 answers

It seems to have worked by getting rid of closing tags and replacing them with tags that close automatically:

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

+25
source share

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

+2
source share

All Android XML files must begin with the line:

 <?xml version="1.0" encoding="utf-8"?> 

so your file should look like this:

 <?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> 
0
source share

Replace tag

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

instead

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

// how wise all tags

0
source share

All Articles