My app uses the Theme.Wallpaper family, which means the current wallpaper is used as the app's background. This may cause readability issues (depending on the user's favorite wallpaper) so I want to allow the user to choose an image as a background.
The way I am trying to implement it is:
@Override
protected void onResume() {
// Get wallpaper preferences to check if user selected a wallpaper and
// display it
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 the resource id of the selected wallpaper.
My problem is the titlebar and actionbar do not respond to this. Is there a way to make them also receive the new background?
Your ActionBar will now sit over the background view, instead of above it. It will be transparent, so as to allow the background to show through, and it will not be covered up by the ActionBar.