意外的名称空间前缀"app"找到标签RelativeLayout-Android? [英] Unexpected namespace prefix "app" found for tag RelativeLayout - Android?

查看:63
本文介绍了意外的名称空间前缀"app"找到标签RelativeLayout-Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将BottomSheetBehaviorScrollView一起使用,但这对我来说是这样的:

I need to use BottomSheetBehavior with ScrollView but it says to me :

Unexpected namespace prefix "app" found for tag RelativeLayout

app:behavior_hideable="true"
app:behavior_peekHeight="80dp"

这是我的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/ABLList"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="end"
                    android:orientation="horizontal">

                    <ImageButton
                        android:id="@+id/imbDetail"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="end|center_vertical"
                        android:layout_marginRight="10dp"
                        android:background="@null"
                        android:src="@drawable/ic_action_detail" />
                </LinearLayout>
            </android.support.v7.widget.Toolbar>

        </android.support.design.widget.AppBarLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_OrderList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/ABLList"
            android:scrollbars="vertical" />
    </RelativeLayout>

    <ScrollView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/layout_bottom_sheet_ListOrder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="top"
            android:background="@color/color_bottom_sheet"
            android:gravity="top"
            app:behavior_hideable="true"
            app:behavior_peekHeight="80dp"
            app:layout_behavior="@string/string_bottom_sheet_behavior">

            <com.example.asheq.utils.TextViewJus
                android:id="@+id/txtAddress"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/text_marginTop"
                android:gravity="right"
                android:maxLines="5"
                android:paddingLeft="@dimen/activity_vertical_margin"
                android:paddingRight="@dimen/activity_vertical_margin"
                android:textSize="@dimen/text_size"
                android:textStyle="bold" />

            <Button
                android:id="@+id/btnSReport"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/txtCTime"
                android:layout_marginTop="50dp"
                android:text="@string/btnReport" />

        </RelativeLayout>
    </ScrollView>

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/coordinatorOrder"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
</android.support.design.widget.CoordinatorLayout>

推荐答案

在布局中使用数据绑定时,此问题众所周知.

This issue is well known in while using data-binding in a layout.

假设您要使用带有app:前缀的某些数据绑定属性,那么仅添加xmlns:app...是不够的.布局应为数据绑定布局,<layout标签包裹.

Assume you want to use some data binding attribute with app: prefix then just adding xmlns:app... will not be enough. layout should be data binding layout wrapped with <layout tag.

例如我导入了layout_toolbar_default.xml并使用app:toolbarTitle指定title.

e.g. I imported layout_toolbar_default.xml and using app:toolbarTitle to specify title.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <include
        layout="@layout/layout_toolbar_default"
        app:toolbarTitle="@{@string/app_name}"
        />

</LinearLayout>

这将显示错误Unexpected namespace prefix "app" found .

This will show error Unexpected namespace prefix "app" found.

使用<layout标签包装布局,因为您使用的是绑定属性.

Wrap your layout with <layout tag because you are using binding attribute.

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <include
            layout="@layout/layout_toolbar_default"
            app:toolbarTitle="@{@string/app_name}"
            />

    </LinearLayout>
</layout>

这篇关于意外的名称空间前缀"app"找到标签RelativeLayout-Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆