2016-10-02 60 views
-1

我在導航視圖應用樣式使用下面的代碼有沒有辦法將主題應用到導航視圖的不同項目?

app:theme="@style/NavigationItemTheme" //NavigationItemTheme is my style. 

它適用同樣的主題,所有的導航項目。我想將不同的主題應用於不同的項目。如何實現請幫助。

是否有可能將不同的主題應用於導航視圖中的不同項目?

回答

0

你的孩子可以添加到您的導航視圖並添加樣式兒童

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="end" 
    android:background="@color/white" 
    android:fitsSystemWindows="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center_horizontal" 
     android:orientation="vertical"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center_horizontal" 
     android:orientation="vertical"/> 
</android.support.design.widget.NavigationView> 
+0

它不工作 –

+0

你應該添加樣式linearlayouts例如 –

相關問題