Android &引用;未绑定前缀";布局xml文件中出现错误

Android &引用;未绑定前缀";布局xml文件中出现错误,android,android-layout,Android,Android Layout,我在activity\u main.XML文件中的app:行上得到一个XML解析错误“unbound prefix” <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height=

我在
activity\u main.XML
文件中的
app:
行上得到一个XML解析错误“
unbound prefix

<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    app:rb_color="#0099CC"
    >
 ...
我是按照你的指示去做的

但是,由于ripple代码是作为单个java文件实现的,而不是将ripple代码构建为库,然后将库合并到我的项目中,所以我只是将ripple源java文件直接放入我的项目中


大概我需要将应用程序更改为其他应用程序,以引用
rb\u颜色来设置它,但如何做到这一点?

您必须在父视图中添加以下行:

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

<RelativeLayout 
    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"
    ....
/>


谢谢。如果父视图是最外面的视图,就像在我的代码发布中一样,这一点就行了。但是,如果我尝试在主RelativeLayout中添加另一个RelativeLayout,并将app:行添加到嵌套的RelativeLayout中,那么即使我将xmlns行添加到嵌套布局中,它也不再起作用。为什么会这样?不管app:attribute在哪里,总是将xmlns:app放在第一个视图中(最外层)。
<RelativeLayout 
    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"
    ....
/>