android - Fullscreen Dialog dismiss icon in black -


this question follow-up android fullscreen dialog confirmation , dismissive actions uses dark theme per image below, , icons displayed in white.

enter image description here


i want display "x" icon in black, because using light theme.

the other question has accepted solution changing actionbar icon looks like:

getsupportactionbar().sethomeasupindicator(android.r.drawable.ic_menu_close_clear_cancel); 

that displaying white x, though using light theme.


i seem remember there way use provided icon, , theme display in black on light background...?

tinting colour of stock icons in way built support-v4 library, , described chris banes on blog:

the drawable tinting methods added in lollipop super useful letting dynamically tint assets. appcompat had own baked in implementation in v21 support library , we’ve extracted drawablecompat in support-v4 use.

drawable drawable = ...;  // wrap drawable future tinting calls work // on pre-v21 devices. use returned drawable. drawable = drawablecompat.wrap(drawable);  // can set tint drawablecompat.settint(drawable, color.red); // ...or tint list drawablecompat.settintlist(drawable, mycolorstatelist); // ...and different tint mode drawablecompat.settintmode(drawable, porterduff.mode.src_over); 

which makes exact code quite simple:

// set x close icon in black drawable drawable = getresources()         .getdrawable(r.drawable.abc_ic_clear_mtrl_alpha); drawable = drawablecompat.wrap(drawable); drawablecompat.settint(drawable, color.black); getsupportactionbar().sethomeasupindicator(drawable); 

related questions:


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -