在Theme属性上获取构建错误

时间:2013-08-21 00:34:25

标签: android themes

我想在Theme中更改几个属性的值。

我查看了文件/platforms/android-15/data/res/themes.xml,并在主题定义中找到了这些属性 -

    <item name="android:panelMenuIsCompact">false</item>
    <item name="android:panelMenuListWidth">296dip</item>

是的,我的清单有 -

 <uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="15" />

在我的styles.xml文件中,我添加了 -

<style name="AppTheme" parent="@android:style/Theme">
    <item name="android:panelMenuIsCompact">false</item>
    <item name="android:panelMenuListWidth">296dip</item>
</style>

当我构建时,这些行会出错 -

 No resource found that matches the given name: attr 'android:panelMenuIsCompact'.
 No resource found that matches the given name: attr 'android:panelMenuListWidth'.

我们知道这些属性是有效的,因为它们位于主题定义中,它们也位于文件attrs.xml中,与themes.xml位于同一目录中。那么问题是什么?

2 个答案:

答案 0 :(得分:0)

如果你看到,那些attrs在Themes.xml中定义。所以你的父母应该是:

<style name="AppTheme" parent="android:Theme">
    <item name="android:panelMenuIsCompact">false</item>
    <item name="android:panelMenuListWidth">296dip</item>
</style>

答案 1 :(得分:0)

Android的public.xml中未指定这些属性,因此您将无法使用它们。您可以查看本地/platforms/android-15/data/res/values/public.xml,也可以查看在线文档 android.R.attr