I have two styles defined in styles.xml and styles.xml(v21). They both include a textAppearance attribute that links to a certain default android text style.
styles.xml
<style name="NotificationTitle">
<item name="android:textAppearance">
@android:style/TextAppearance.StatusBar.EventContent.Title
</item>
</style>
styles.xml (v21)
<style name="NotificationTitle">
<item name="android:textAppearance">
@android:style/TextAppearance.Material.Notification.Title
</item>
</style>
These default styles contain some text attributes: textColor, textSize, etc:
...
<style name="TextAppearance.Material.Notification.Title">
<item name="textColor">@color/primary_text_default_material_light</item>
<item name="textSize">@dimen/notification_title_text_size</item>
</style>
...
I need to get this textColor programmatically by the name of my custom style (NotificationTitle in the example). I tried to obtain it using obtainStyledAttributes, but it don't return. What should I do?
int resultColor;
int[] attrs = {android.R.attr.textColor};
TypedArray ta = context.obtainStyledAttributes(R.style.NotificationText, attrs);
if (ta != null) {
resultColor = ta.getColor(0, Color.TRANSPARENT);
ta.recycle();
}
android.R.style.TextAppearance_Material_Notification_TitleintoobtainStyledAttributesit will return the right color. But if I pass my custom styleR.style.NotificationTextit won't return anything.