Simranjeet Singh
Simranjeet Singh

Reputation: 69

Why colour is not changing in the vector?

<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

Upvotes: 1

Views: 221

Answers (1)

SynAck
SynAck

Reputation: 426

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;

}

Upvotes: 1

Related Questions