Created
July 28, 2014 09:01
-
-
Save tbruyelle/c2f852aafbaceda82bdf to your computer and use it in GitHub Desktop.
Android get ColorBackground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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