1
votes

I have an error "Unexpected namespace prefix "xmlns" found for tag LinearLayout" in "xmlns:android="http://schemas.android.com/apk/res/android" in LinearLayout.

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

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
            android:background="@drawable/wallpaper"
    android:layout_height="match_parent" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>
    </ScrollView>
3

3 Answers

4
votes

There is no need for placing namespace attribute for every Layout you defined in you layout.xml files. Namespace can be defined for a root level element only as below:

 <?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
        android:background="@drawable/wallpaper"
android:layout_height="match_parent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>
</ScrollView>
0
votes

Remove this line

xmlns:android="http://schemas.android.com/apk/res/android"

from your LinearLayout. You only add that once, in your root layout. You can only define a namespace once in each xml

0
votes

The XML appears to be well-formed. You can perhaps circumvent the problems by changing the XML, but that doesn't explain why you are getting the error. I think we need to know more about how you are parsing the XML. Check whether other XML parsers accept it.