I want to apply some style to DatePicker
. In platform's attrs.xml
we can see following attributes for DatePicker
styleable:
<declare-styleable name="DatePicker">
...
<!-- The text color for the selected date header text, ex. "2014" or
"Tue, Mar 18". This should be a color state list where the
activated state will be used when the year picker or day picker is
active.-->
<attr name="headerTextColor" format="color" />
<!-- The background for the selected date header. -->
<attr name="headerBackground" />
...
</declare-styleable>
While I can refer to android:headerBackground
, unexpectedly I cannot do that for android:headerTextColor
attribute. So following code in styles.xml
:
<style name="MyDatePickerStyle" parent="@android:style/Widget.Material.DatePicker">
<item name="android:headerBackground">@color/red</item>
<item name="android:headerTextColor">@color/red</item>
</style>
prompts with error, that android:headerTextColor
cannot be resolved.
But I can clearly see Widget.Material.DatePicker
overriding that attribute. Interestingly that chunk of code is preceded with Attributes for new-style DatePicker
comment, which may somehow lead to the cause of this behavior.
What maybe the cause of this behavior and how to override that attribute?
Running on Android Studio 2.3, minSdkVersion 23, buildToolsVersion 25.0.3, compileSdkVersion & targetSdkVersion 23, invalidated caches and cleaned project.
As you can see in R.attr
docs, there is this text behind some attributes:
This constant was deprecated in API level 23. Use headerTextColor instead.
Which means, that this attribute should be exposed to public API, but somehow it is being stripped and AAPT cannot access it.
Opened an issue at bug tracker.
Try to use this
Style.xml
Values folder attr.xml