android - MenuItem tinting on AppCompat Toolbar -
android - MenuItem tinting on AppCompat Toolbar -
when utilize drawables appcompat
library toolbar
menu items tinting works expected. this:
<item android:id="@+id/action_clear" android:icon="@drawable/abc_ic_clear_mtrl_alpha" <-- appcompat android:title="@string/clear" />
but if utilize own drawables or re-create drawables appcompat
library own project not tint @ all.
<item android:id="@+id/action_clear" android:icon="@drawable/abc_ic_clear_mtrl_alpha_copy" <-- re-create appcompat android:title="@string/clear" />
is there special magic in appcompat
toolbar
tint drawables library? way work own drawables?
running on api level 19 device compilesdkversion = 21
, targetsdkversion = 21
, , using appcompat
abc_ic_clear_mtrl_alpha_copy
exact re-create of abc_ic_clear_mtrl_alpha
png appcompat
edit:
the tinting based on value have set android:textcolorprimary
in theme.
e.g. <item name="android:textcolorprimary">#00ff00</item>
give me greenish tint color.
screenshots
tinting working expected drawable appcompat
tinting not working drawable copied appcompat
because if take @ source code of tintmanager in appcompat, see:
/** * drawables should tinted value of {@code r.attr.colorcontrolnormal}, * using default mode. */ private static final int[] tint_color_control_normal = { r.drawable.abc_ic_ab_back_mtrl_am_alpha, r.drawable.abc_ic_go_search_api_mtrl_alpha, r.drawable.abc_ic_search_api_mtrl_alpha, r.drawable.abc_ic_commit_search_api_mtrl_alpha, r.drawable.abc_ic_clear_mtrl_alpha, r.drawable.abc_ic_menu_share_mtrl_alpha, r.drawable.abc_ic_menu_copy_mtrl_am_alpha, r.drawable.abc_ic_menu_cut_mtrl_alpha, r.drawable.abc_ic_menu_selectall_mtrl_alpha, r.drawable.abc_ic_menu_paste_mtrl_am_alpha, r.drawable.abc_ic_menu_moreoverflow_mtrl_alpha, r.drawable.abc_ic_voice_search_api_mtrl_alpha, r.drawable.abc_textfield_search_default_mtrl_alpha, r.drawable.abc_textfield_default_mtrl_alpha }; /** * drawables should tinted value of {@code r.attr.colorcontrolactivated}, * using default mode. */ private static final int[] tint_color_control_activated = { r.drawable.abc_textfield_activated_mtrl_alpha, r.drawable.abc_textfield_search_activated_mtrl_alpha, r.drawable.abc_cab_background_top_mtrl_alpha }; /** * drawables should tinted value of {@code android.r.attr.colorbackground}, * using {@link android.graphics.porterduff.mode#multiply} mode. */ private static final int[] tint_color_background_multiply = { r.drawable.abc_popup_background_mtrl_mult, r.drawable.abc_cab_background_internal_bg, r.drawable.abc_menu_hardkey_panel_mtrl_mult }; /** * drawables should tinted using state list containing values of * {@code r.attr.colorcontrolnormal} , {@code r.attr.colorcontrolactivated} */ private static final int[] tint_color_control_state_list = { r.drawable.abc_edit_text_material, r.drawable.abc_tab_indicator_material, r.drawable.abc_textfield_search_material, r.drawable.abc_spinner_mtrl_am_alpha, r.drawable.abc_btn_check_material, r.drawable.abc_btn_radio_material }; /** * drawables contain other drawables should tinted. kid drawable ids * should defined in 1 of arrays above. */ private static final int[] containers_with_tint_children = { r.drawable.abc_cab_background_top_material };
which pretty much means have particular resourceids whitelisted tinted.
but guess can see how they're tinting images , same. it's easy set colorfilter on drawable.
android toolbar appcompat tint
Comments
Post a Comment