Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了无法从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中所看到的,这些文本背后有一些属性

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

在bug跟踪器上打开an issue.

解决方法

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

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

大佬总结

以上是大佬教程为你收集整理的无法从android命名空间解析属性全部内容,希望文章能够帮你解决无法从android命名空间解析属性所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。