Skip to content

Instantly share code, notes, and snippets.

@tbruyelle
Created July 28, 2014 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbruyelle/c2f852aafbaceda82bdf to your computer and use it in GitHub Desktop.
Save tbruyelle/c2f852aafbaceda82bdf to your computer and use it in GitHub Desktop.
Android get ColorBackground
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.colorBackground, tv, true);
if (tv.type >= TypedValue.TYPE_FIRST_COLOR_INT && tv.type <= TypedValue.TYPE_LAST_COLOR_INT) {
// windowBackground is a color
setBackgroundColor(tv.data);
} else {
// windowBackground is not a color, probably a drawable
setBackgroundDrawable(getResources().getDrawable(tv.resourceId));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment