我在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) 您可以通过不正确的名称空间或属性中的输入错误看到此错误.就像"xmlns"是错的,它应该是xmlns:android

2) 第一个 node 需要包含:

3)如果您正在集成AdMob,请判断自定义参数,如ads:adSize,您需要

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

4) 如果使用LinearLayout,则可能需要定义工具:

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

Android相关问答推荐

在Android中点击滑动时触发的手势

以正确的方式从房间收集流量

Android添加设置图标齿轮到应用程序信息

无法从API访问项目详细信息

如何在停止和销毁时更改函数中Firebase实时数据库的子项的值我试过了,但这不起作用.请使用Kotlin

strings.xml中字符串数组中的占位符

更改Jetpack Compose中选定的选项卡底线 colored颜色

Jetpack Compose主导航中的全屏图标列表

为什么我有多个Player实例?

从惰性列中删除项目时Jetpack Compose崩溃

我怎样才能画一条线在喷气背包组成和有一个自定义的角落?

为什么可以';我不能直接在RecyclerView.ViewHolder中访问视图ID吗?

如何在使用 PointerInput 修改器时添加点击时的波纹效果

Android Drawable文件夹中的图像显示模糊

当手表与手机断开连接时,有没有办法在我的 Wear OS 应用程序中显示操作系统级别的图标?

Kotlin Multiplatform Mobile targetSdk 已弃用

如何关闭可组合对话框?

重命名列失败的房间自动迁移(NOT NULL 约束失败,生成错误的迁移类)

从expose 的 dropdownMenu 可组合、jetpack 组合中 Select 选项时,不会触发文本字段的 onValueChange

单个用户可以在 Firebase 身份验证中将多个电话号码链接到他的帐户吗?