Created
June 30, 2015 08:07
-
-
Save alorma/4f6c4c8e424a8c96b4ed to your computer and use it in GitHub Desktop.
getTheme colors
This file contains hidden or 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
private int fetchPrimaryColor() { | |
int colorAccent = Color.parseColor("#FF0000"); | |
int attr = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.attr.colorPrimary : R.attr.colorPrimary; | |
TypedArray a = getContext().getTheme().obtainStyledAttributes(new int[]{attr}); | |
colorAccent = a.getColor(0, colorAccent); | |
a.recycle(); | |
return colorAccent; | |
} | |
private int fetchAccentColor() { | |
int colorAccent = Color.parseColor("#00FF00"); | |
int attr = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.attr.colorAccent : R.attr.colorAccent; | |
TypedArray a = getContext().getTheme().obtainStyledAttributes(new int[]{attr}); | |
colorAccent = a.getColor(0, colorAccent); | |
a.recycle(); | |
return colorAccent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment