gpt4 book ai didi

java - 无法将 Appcompat 主题从浅色更改为全黑

转载 作者:搜寻专家 更新时间:2023-10-30 20:56:32 26 4
gpt4 key购买 nike

我正在尝试完全更改我的应用程序的主题,这是我修改并尝试过的:

值文件夹中的

styles.xml

<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

values-v11 styles.xml

<resources>

<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
<!-- API 11 theme customizations can go here. -->
</style>

</resources>

values-v14 styles.xml

<resources>

<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
<!-- API 14 theme customizations can go here. -->
</style>

</resources>

主要文件

<application
.....
android:theme="@style/AppTheme" >
.......
</application>

我正在使用 ActionBarActivityappcompat_v7 但应用因 java.lang.RuntimeException: Unable to start activity ComponentInfo{com...}: java 而崩溃.lang.IllegalStateException:您需要在此 Activity 中使用 Theme.AppCompat 主题(或后代)

我是不是漏掉了什么……?

我该如何解决这个问题?

请帮忙...

提前致谢!


编辑:使用 Appcompat 主题时,主题很轻,代码是:

因此,使用 appcompat 主题我的 styles.xml 在 values 文件夹中是

<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

values-v11 styles.xml

<resources>

<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>

</resources>

values-v14 styles.xml

<resources>

<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

</resources>

主要文件

<application
.....
android:theme="@style/AppTheme" >
.......
</application>

而且我不知道如何将 appcompat 主题从浅色更改为全黑。请帮忙

最佳答案

正如 tyczj 所指出的,如果您的应用使用 appcompat_v7,您需要使用 Theme.AppCompat 作为主题的父级。 Theme.AppCompat 在视觉上与 Theme.Holo(深色)相同。

参见 article about styling the ActionBar在 Android 文档上获取更多信息。

关于java - 无法将 Appcompat 主题从浅色更改为全黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25162657/

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