envyM6 envyM6 - 5 months ago 62
Android Question

Customising Default Navigation Drawer Activity Vector Icons

I'm trying to customise and colourise the default

Navigation Drawer Activity
on Android Studio 2.1.2. I've changed the color of
ic_menu_camera.xml
file in following way--

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#f73a3a" //changed colour
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
<path
android:fillColor="#f73a3a" //changed colour
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
</vector>


The colour changes in the preview window as per screenshot below-

enter image description here

However, colour is changed again to default black/dark grey when the app is launched--

enter image description here

How can I implement the changed color here?

Answer

You need to set the setItemIconTintList to null during onCreate

YourView.setItemIconTintList(null);

Now you can edit the vector assets directly and the changes will show.