属性引用太多警告。可能的原因?

时间:2015-10-22 14:10:26

标签: android styling

我开发了一个应用程序,并注意到我在logcat中收到了很多“Too many attributes references”警告。

W/ResourceType﹕ Too many attribute references, stopped at: 0x########

我使用support.v7.23.1.0也设计库。我定义了这样的样式:

 <style name="AppTheme.Description.TextView" parent="@android:style/Widget.TextView">
        <item name="android:textColor">@color/textColorSecondary</item>
        <item name="android:textColorPrimary">@color/textColorSecondary</item>
        <item name="android:textSize">@dimen/textSizeItemDescription</item>
    </style>

应用主题:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:textColorHighlight">@color/colorPrimaryLight</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <!--status bar background color-->
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <!-- color of drawer toggle and other stuff-->
    <item name="android:textColorSecondary">@color/textColorSecondary</item>
    <!-- Used to define what color preference categories titles will be-->
    <item name="colorAccent">@color/colorAccent</item>
    <!--overrides text color secondary for widgets and action mode     -->
    <item name="colorControlNormal">@color/colorControlNormal</item>
    <!--when widget is activated for text writing or stuff  -->
    <item name="colorControlActivated">@color/colorPrimaryLight</item>
    <!--when menu items are being Clicked -->
    <item name="colorControlHighlight">@color/colorPrimaryLight</item>
    <!--used in all areas where text color is needed (TextViews, Spinners, etc)-->
    <item name="android:textColor">@color/textColor</item>
    <!--used in text inputs like EditText-->
    <item name="android:textColorPrimary">@color/textColorPrimary</item>
    <!--main application background-->
    <item name="android:colorBackground">@color/colorBackground</item>
    <item name="drawerArrowStyle">@style/Theme.DrawerArrowStyle</item>
    <!--Context action meniu will overlay toolbar-->
    <item name="windowActionModeOverlay">true</item>
    <item name="toolbarStyle">@style/AppTheme.Toolbar</item>

</style>

我搜索了这个问题,但我发现的只有:

TextView txtView= new TextView(new ContextThemeWrapper(context, R.style.styleName));

但我的应用程序中没有那种代码。

我想知道导致此警告的原因是什么?

更新2015-10-22 17:30 我有些如何通过更改所有自定义样式来解决这个问题

<style name="AppTheme.Description.TextView" parent="">
        <item name="android:textColor">@color/textColorSecondary</item>
        <item name="android:textColorPrimary">@color/textColorSecondary</item>
        <item name="android:textSize">@dimen/textSizeItemDescription</item>
    </style>

我的意思是我让父母空了。不确定这是好的解决方案还是坏的?

1 个答案:

答案 0 :(得分:9)

我遇到了同样的问题,并且在某些时候创建了一个属性链。通过删除父母,链条被打破,所以你应该好。