2015-11-11 60 views
1

我想將Toolbar小部件添加到我的應用程序中。所以當我將xml代碼添加到佈局文件時,我得到了Unbound前綴錯誤。我該怎麼做才能解決這個問題?在Eclipse中解析XML時出現無約束前綴錯誤

我layout.xml

<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:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.dizikolikk.MainActivity" > 


<android.support.v7.widget.Toolbar 

    android:id="@+id/my_toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    android:elevation="4dp" 
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

</RelativeLayout> 

回答

5

當您在XML佈局中使用一個未定義的命名空間(在這種情況下,它的「應用」命名空間)

您需要添加

出現此錯誤
xmlns:app="http://schemas.android.com/apk/res-auto" 

到您的XML佈局。

相關問題