无法从android命名空间解析属性

我想将一些样式应用于DatePicker.在 platform’s attrs.xml中,我们可以看到DatePicker样式的以下属性
<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>

虽然我可以引用android:headerBackground,但我不能为android:headerTextColor属性做到这一点.所以在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>

提示错误,表示android:headerTextColor无法解析.

但我可以clearly see Widget.Material.DatePicker覆盖该属性.有趣的是,大量代码前面有新式DatePicker注释的属性,这可能会以某种方式导致此行为的原因.

可能是这种行为的原因以及如何覆盖该属性

在Android Studio 2.3上运行,minSdkVersion 23,buildToolsversion 25.0.3,
compileSdkVersion& targetSdkVersion 23,无效的缓存和清理的项目.

正如您在R.attr docs中所看到的,这些文本背后有一些属性

This constant was deprecated in API level 23. Use headerTextColor instead.

这意味着,该属性应该暴露给公共API,但不知何故它被剥离,AAPT无法访问它.

在bug跟踪器上打开an issue.

解决方法

style attribute android:attr/headerTextColor is private

AAPT说该属性是私有的.可能他们错过了attrs.xml中的@hide

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...