我在android视图中经常出现问题,错误解析XML:第2行未绑定前缀。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:id="@+id/myScrollLayout" 
android:layout_width="fill_parent"  android:layout_height="wrap_content">
    <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" 
    android:text="Family" android:id="@+id/Family" 
    android:textSize="16px" android:padding="5px" 
    android:textStyle="bold" android:gravity="center_horizontal">
    </TextView>

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:orientation="vertical" android:scrollbars="vertical">
        <LinearLayout android:orientation="vertical" android:id="@+id/myMainLayout" 
        android:layout_width="fill_parent"  android:layout_height="wrap_content">
        </LinearLayout>
    </ScrollView>

</LinearLayout>

当前回答

您只需要在根标记中添加适当的名称空间。 xmlns: android = " http://schemas.android.com/apk/res/android " Android元素是在这个名称空间中声明的。它与导入类或包相同。

其他回答

您只需要在根标记中添加适当的名称空间。 xmlns: android = " http://schemas.android.com/apk/res/android " Android元素是在这个名称空间中声明的。它与导入类或包相同。

对于新手和像我这样不了解XML的人,我将多讲一些内容。

上面的答案非常好,但是一般的答案是您需要为config.xml文件中使用的任何名称空间设置一个名称空间。

翻译:任何XML标记名都是带有名称空间的标记,其中blah是名称空间,fubar是XML标记。名称空间允许您使用许多不同的工具来解释带有自己标记名称的XML。例如,Intel XDK使用的命名空间为intelxdk, android使用的命名空间为android。因此,您需要以下名称空间,否则构建会引发流血(即解析XML错误:未绑定的前缀),这将被翻译为:您使用了一个名称空间,但没有定义它。

  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:intelxdk="http://xdk.intel.com/ns/v1"

如果您没有正确地包含xmlns:mm,则通常会出现此错误,它通常出现在代码的第一行。

对我来说…

xmlns:mm=“http://millennialmedia.com/android/schema”

我在第一行代码中漏掉了

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mm="http://millennialmedia.com/android/schema"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:background="@android:color/transparent" >

ViewPager指示器的unbound前缀错误:

在你的parentLayout中伴随着下面的头标签:

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

也添加:

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

这招对我很管用。

我要加一个单独的答案,因为我在这里没有看到。这不是Pentium10所要求的100%,但我在这里搜索了“错误解析XML:未绑定前缀”

事实证明,我为AdMob广告使用了自定义参数,如ads:adSize,但我还没有添加

    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

对布局。一旦我添加它,它工作得很好。