gpt4 book ai didi

android - 在旧版 Android 中使用 AppCompat 主题更改主题 Activity 的背景颜色

转载 作者:行者123 更新时间:2023-11-29 19:26:29 24 4
gpt4 key购买 nike

我正在为我的应用程序使用以下主题:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

我想改变背景颜色。为此,根据文档,我可以将以下内容添加到主题定义中:

    <item name="windowBackground">@color/windowBackground</item>

不幸的是,只有在(如 No resource found that matches the given name: attr 'windowBackground' 的答案中所建议的)我将其限制为应用于具有 API 21 或更高版本的 Android 版本时,才能正确编译。

我如何才能在早期版本的 Android 上使用它?理想情况下,我想为低至 API 16 的 Android 版本指定背景颜色,这是我目前的最低要求。

最佳答案

正如您所说的那样,windowBackground 是正确的,因此您只需将其替换为适用于 API 14 及更高版本的 android:windowBackground

关于android - 在旧版 Android 中使用 AppCompat 主题更改主题 Activity 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41295313/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com