Android 错误:分析XML时出错:XML中的未绑定前缀
我试图在我的项目中使用cardview,但是当我为我的cardview创建XML文件时,我不断得到错误 错误:分析XML时出错:未绑定前缀 但如果我拿出我的cardview小部件,它就会工作。我看了其他问题并尝试了他们的回答,但没有效果。有人看到我的代码有什么问题吗Android 错误:分析XML时出错:XML中的未绑定前缀,android,Android,我试图在我的项目中使用cardview,但是当我为我的cardview创建XML文件时,我不断得到错误 错误:分析XML时出错:未绑定前缀 但如果我拿出我的cardview小部件,它就会工作。我看了其他问题并尝试了他们的回答,但没有效果。有人看到我的代码有什么问题吗 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/an
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
card_view:cardCornerRadius="2dp" >
</android.support.v7.widget.CardView>
</LinearLayout>
试试这个
<LinearLayout
xmlns:card_view="http://schemas.android.com/apk/res-auto"
试试这个
<LinearLayout
xmlns:card_view="http://schemas.android.com/apk/res-auto"
您应该添加xmlns:card\u view=”http://schemas.android.com/apk/res-auto“
这适用于您的父布局
您应该添加
xmlns:card\u view=”http://schemas.android.com/apk/res-auto“
这是您的父布局您缺少卡片视图的前缀
。只是错过了。谢谢您缺少card\u view
的前缀。只是错过了。谢谢,不必为父布局定义名称空间,也可以为cardview定义名称空间如果将其添加到父布局,则不必对添加的所有视图重复。不必为父布局定义名称空间,也可以为cardview定义名称空间如果将其添加到父布局,则不必对添加的所有视图重复。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
card_view:cardCornerRadius="2dp" >
</android.support.v7.widget.CardView>