ricardoalcocer / actionbarextras

Titanium Android Native Module that exposes ActionBar features not exposed by the Titanium SDK
MIT License
148 stars 60 forks source link

Feature Request: Tint/Color the up button #83

Closed viezel closed 9 years ago

viezel commented 9 years ago

The up button does not match in design when changing the color of title and subtitle.

Ricardo found this in a google search:

final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(getResources().getColor(R.color.grey), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);

I have used this piece of code in a project once for tinting the actionbar icons:

    // Helper to tint the actionbar icons
    public static void tintMenuItem(String id, Menu menu){
        MenuItem item = menu.findItem(RHelper.getId(id));
        Drawable newIcon = (Drawable)item.getIcon();
        newIcon.mutate().setColorFilter(NappApplication.getActionBarIconColor(), PorterDuff.Mode.SRC_IN);
        item.setIcon(newIcon);
    }

    public static void tintMenuItem(int id, Menu menu){
        MenuItem item = menu.findItem(id);
        Drawable newIcon = (Drawable)item.getIcon();
        newIcon.mutate().setColorFilter(NappApplication.getActionBarIconColor(), PorterDuff.Mode.SRC_IN);
        item.setIcon(newIcon);
    }
manumaticx commented 9 years ago

Hi @viezel sorry for the late reply. Thanks for your example code. I think this should work fine. I'll have a look now.

manumaticx commented 9 years ago

Thank you, Mads! It works as expected :+1: