开发者社区> 问答> 正文

android视图中经常遇到问题,Error parsing XML:unbound prefix

我在Android视图中经常遇到这个错误: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>

展开
收起
蛮大人123 2016-06-16 10:46:33 2861 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    这个错误可能发生在你没有定义前缀的情况下,像这样:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <TabHost
        XYZ:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </TabHost>

    因为它还没有被定义,所以android编译器不知道什么是XYZ。
    在你的情况下,你需要将下边的定义添加到xml文件的根节点中。
    xmlns:android="http://schemas.android.com/apk/res/android"

    2019-07-17 19:40:30
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载