【问题标题】:No resource found that matches the given name: attr 'colorBackground'找不到与给定名称匹配的资源:attr 'colorBackground'
【发布时间】:2015-06-29 18:14:43
【问题描述】:

我正在尝试在此处编辑ThemeOverlay,其中包含有关弹出窗口和对话框之类的露水错误,但问题是它不接受colorBackground 属性。

我知道有些人会说我应该使用android:colorBackground,但如果我是从 AppCompat 继承的,那么这应该不是问题。 请帮忙。

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
    <!-- Customize your theme here. -->
</style>

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/Primary</item>
    <item name="colorPrimaryDark">@color/PrimaryDark</item>
    <item name="colorAccent">@color/Accent</item>
</style>

<style name="PopupTheme" parent="ThemeOverlay.AppCompat.Light">
    <item name="colorBackground">@color/TextColor</item>
</style>
</resources>

此外,即使在应用android:colorBackground 之后它也不起作用。错误消失了,但我想要完成的事情没有发生。

【问题讨论】:

    标签: android android-layout android-xml android-styles


    【解决方案1】:

    尝试更改为:

    <style name="PopupTheme" parent="ThemeOverlay.AppCompat.Light">
        <item name="android:background">@color/TextColor</item>
    </style>
    

    我认为您正在尝试更改背景,为什么不使用图像:

     <item name="android:background">@drawable/your_drawable</item>
    

    【讨论】:

    • 同样的事情。错误消失了,但没有完成工作。我想改变弹出窗口的背景颜色,就像在工具栏上一样。如果你愿意,我可以发布工具栏代码,也许那里有问题。
    【解决方案2】:

    改变

    <style name="PopupTheme" parent="ThemeOverlay.AppCompat.Light">
         <item name="colorBackground">@color/TextColor</item>
    </style>
    

    <style name="PopupTheme" parent="ThemeOverlay.AppCompat.Light">
         <item name="android:windowBackground">@color/TextColor</item>
    </style>
    

    【讨论】:

      猜你喜欢
      • 2017-10-13
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多