android: set background color for the entire screen dynamically, or how to set actionbar to overlay layout, but not overlap content -
my app uses theme.wallpaper family, means current wallpaper used app's background. may cause readability issues (depending on user's favorite wallpaper) want allow user choose image background.
the way trying implement is:
@override protected void onresume() { // wallpaper preferences check if user selected wallpaper , // display sharedpreferences wallpaperpref = getsharedpreferences(wallpaperactivity.wallpaper_preferences, mode_private); int selectedwallpaper = wallpaperpref.getint(wallpaperactivity.selected_wallpaper, 0); if (selectedwallpaper != 0) { findviewbyid(r.id.pager).setbackgroundresource(selectedwallpaper); getsupportactionbar().setbackgrounddrawable(getresources().getdrawable(selectedwallpaper)); } else { findviewbyid(r.id.pager).setbackgroundcolor(color.transparent); getsupportactionbar().setbackgrounddrawable(new colordrawable(color.transparent)); } super.onresume(); }
the shared preference contains resource id of selected wallpaper.
my problem titlebar , actionbar not respond this. there way make them receive new background?
- make background of title bar , action bar transparent.
- set window actionbar overlay true.
- pad main view height of actionbar actionbar doesn't cover of content.
your actionbar sit on background view, instead of above it. transparent, allow background show through, , not covered actionbar.
Comments
Post a Comment