2017-06-03 49 views
0

解決,下面的代碼都OK,外部庫造成這個問題。找到粗野,報關去

我有一個自定義的主題NavigationView在我style

<android.support.design.widget.NavigationView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:itemTextColor="@color/nav_state_list" 
     app:menu="@menu/drawer_menu" 
     app:headerLayout="@layout/nav_header" 
     app:itemTextAppearance="@style/NavDrawerTextStyle" 
android:theme="@style/navTheMe" 

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

風格(navTheMe)

<style name="navTheMe" parent="AppThemee"> 
    <item name="android:textSize">12sp</item> 
    <item name="android:textStyle">bold</item> 
    <item name="listPreferredItemPaddingRight">90dip</item> 
</style> 

但找不到我的主題,它說:

找不到聲明去

我的主題將不會被應用

它一直小時,我無法弄清楚到底是怎麼回事

回答

0

您應該刪除第二Ë屬性在style.xml

<style name="navTheMe" parent="AppTheme"> 
    <item name="android:textSize">12sp</item> 
    <item name="android:textStyle">bold</item> 
    <item name="listPreferredItemPaddingRight">90dip</item> 
</style> 

並且還,這種新的主題應用到您的NavigationView佈局,你應該使用應用:主題= 「」 @風格/ navTheMe 「屬性,而不是機器人:主題=」 @風格/ navTheMe

<android.support.design.widget.NavigationView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    ... 
    app:theme="@style/navTheMe"> 
     ... 
</android.support.design.widget.NavigationView> 
+0

感謝您的答覆,'Appthemee'是我的主題名稱。我已經改變了'android'前綴'app',它是尋找我的主題,但現在,它仍然是不應用它 – DastakWall

+0

你能後的** Appthemee **主題?謝謝 – BigNick

+0

我剛剛發現問題,最近我在我的項目中添加了一個庫,我剛剛意識到,庫導致了這個問題,我不知道爲什麼,所以我從我的項目中刪除它, m使用具有相同功能的另一個庫,我感謝您的幫助順便說一句 – DastakWall