I’m building my first Android program from a book. It kept crashing on an XML file. I downloaded the xml code from the book, used it and it ran fine!
When I look at them, they both look the same to me! Am I missing something about XML – are there funny empty space problems, capitals, special characters or has my XML just got an odd gremlin in it!
It’s working now, but I’d like to know why.
This works!
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip">
<TextView
android:id="@+id/about_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_text" />
</ScrollView>
This doesn’t work: crashes with: java.lang.runtime.exception. Binary xml file lin #1: You must supply layout_width attribute.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android.layout_width="fill_parent"
android.layout_height="fill_parent"
android:padding="10dip">
<TextView
android:id="@+id/about_content"
android.width ="wrap_content"
android.height ="wrap_content"
android:text="@string/about_text"/>
</ScrollView>
In the XML that does not work, you’ve got periods (
.) in the attribute names:and
which need to use colons (
:) instead:and