I have been struggling to obtain the styled attributes with the pre-lollipop API.
With lollipop, I use
final TypedValue statusBarColor = new TypedValue();
getTheme().resolveAttribute(android.R.attr.colorPrimaryDark, statusBarColor, true);
STATUS_BAR_COLOR = ContextCompat.getColor(this, statusBarColor.resourceId);
This works flawlessly, I haven't found a similar way to do this below API version 21. (minAPI = 16)
I tried using the getTheme().obtainStyledAttributes()
. But, I don't have the AttributeSet
to provide to that method since I am using this inside an activity. Am I doing things completely wrong, or is resolving styled attributes not supported on API versions below 21?