1
<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="#FF408100"
        android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" />
</vector>

i am dealing with bottomnavigationview i want that the home icon can change its colour initially but it is not working i have already tried restarting and refreshing the pc and one more thing i also want that it change custom color when i click the icon but unable to find out the way without placing other image of same colour in drawable

Any help would be appreciatedhome svg is black but colour is set to green

  • Hi @Simranjeet Signh, if you're using `BottomNavigationView`, this is the best answer for you: https://stackoverflow.com/questions/42346899/bottomnavigationbar-change-the-tab-icon-color – SonhnLab Jul 05 '18 at 03:37

1 Answers1

1

You can color custom icons as

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);

    for(int i = 0; i < menu.size(); i++){
        Drawable drawable = menu.getItem(i).getIcon();
        if(drawable != null) {
            drawable.mutate();
            drawable.setColorFilter(Color.parseColor("#FF408100"), PorterDuff.Mode.SRC_ATOP);
        }
    }

    return true;

}

SynAck
  • 427
  • 5
  • 19