2017-08-20 25 views
0

我在這裏使用的圖標都是彩色的,但不會在運行中顯示。 我嘗試了應用程序:itemIconTint =「@ null」在xml中,但沒有用。不能使用幻燈片抽屜的彩色圖標

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

    <item android:id="@+id/home" 
     android:title="@string/home" 
     android:icon="@drawable/icon_home" 
     app:itemIconTint="@null"/> 

    <item android:id="@+id/help" 
     android:title="@string/help" 
     android:icon="@drawable/icon_help"/> 
</menu> 

enter image description here

**這是另一種版式文件是幻燈片抽屜就會出現。我已經刪除了不必要的代碼,使之簡單**

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      ........../> 

    </LinearLayout> 

    <android.support.v4.widget.DrawerLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.design.widget.NavigationView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:menu="@menu/navigation" 
      android:layout_gravity="start"> 

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

    </android.support.v4.widget.DrawerLayout> 
</RelativeLayout> 
+0

你在使用NavigationView @ Aryan嗎? –

+0

是的,我正在使用導航視圖,我也添加了XML代碼。 –

+0

將此添加到您的活動@Aryan –

回答

1

添加到您的活動

navi_view.setItemIconTintList(null); 

其中navi_view是你NavigationView的對象。