xml - android View 中经常出现的问题,解析XML时出错: unbound prefix

标签 xml android eclipse android-linearlayout

我在 android View 中经常遇到问题,Error parsing XML: unbound prefix on Line 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>

最佳答案

发生这种情况的几个原因:

1) 您看到此错误的 namespace 不正确,或属性中存在拼写错误。像'xmlns'是错误的,应该是xmlns:android
2)第一个节点需要包含:xmlns:android="http://schemas.android.com/apk/res/android"
3) 如果您正在集成 AdMob,请检查自定义参数,例如 ads:adSize , 你需要
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
4) 如果您使用LinearLayout您可能必须定义工具:
xmlns:tools="http://schemas.android.com/tools"

关于xml - android View 中经常出现的问题,解析XML时出错: unbound prefix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54089735/

相关文章:

Android 3G/2G 控制API?

java - 使用 Samsung Galaxy S3 为 Android 设置 SEEK

java - Eclipse Californium CoAP 通配符作为 url 路径

eclipse - 无法为 Eclipse 安装 Cobertura 插件

javascript - 如何使用 libxmljs (Node.js) 处理子 Node

PHP/MySQL/XML 给出错误

未从 XHTML 输出中删除 XML 序言/指令

android - 单击 Urban Airship 的推送通知打开 Android 应用程序?

C++ HelloWorld 打印不正确

python - 使用lxml添加一个字符串作为子元素