2016-12-05 39 views
2

我需要使用BottomSheetBehaviorScrollView但說我:爲標籤RelativeLayout找到意外的命名空間前綴「app」 - Android?

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> 
+2

對於某人爲textView獲取錯誤「Unexpected namespace prefix」app「found」,您可能需要將「TextView」更改爲「android.support.v7.widget.AppCompatTextView」 –

回答

1
xmlns:app="http://schemas.android.com/apk/res-auto" 

此設置多次。在CoordinatorLayout和RelativeLayout中。 刪除RelativeLayout中的一個。 在文件中聲明一次就足夠了。

1

如果您要多次使用它,請嘗試在父佈局中設置您的xmlns命名空間。

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

在您的父母CoordinatorLayout中寫一次這個聲明就足夠了。

提示:使用多個佈局和視圖時,嘗試實現<include/>屬性。它會使你的代碼乾淨易讀。