简体   繁体   English

如何强制我的小部件使用深色主题?

[英]How can I force my Widgets to use a dark theme?

In my application, I used Theme.Holo.Light to make the ActionBar look light and I am pretty pleased with the result. 在我的应用程序中,我使用Theme.Holo.Light使ActionBar看起来很亮,我对此结果感到非常满意。

The only problem is that all my widgets (EditText, Spinner, etc..) are acting like the background was white, while I set it a dark blue: 唯一的问题是我所有的小部件(EditText,Spinner等)的行为都像背景是白色的,而我将其设置为深蓝色:

在此处输入图片说明

Is there an easy way in the style.xml file where I can force everything to act like the theme was dark? 在style.xml文件中是否有一种简单的方法可以强制所有操作,使主题像黑暗的一样?

I know that I could theme the text color, background resources, etc.. But this would be a huge work. 我知道我可以为文本颜色,背景资源等设置主题。但这将是一项巨大的工作。

Thank a lot for any hint that could help me to achieve that easily. 非常感谢您提供任何可以帮助我轻松实现目标的提示。

Edit: what sounds the best solution, but not working: 编辑:听起来最好的解决方案,但不起作用:

<style name="AppBaseTheme" parent="@android:Theme.Holo">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
</style>

To solve this (the easy way) you should use Theme.Holo . 要解决此问题(简便方法),应使用Theme.Holo And Change the actionbar to Theme.Holo.Light . 并将操作栏更改为Theme.Holo.Light

extend theme: 扩展主题:

<style name="MyTheme.Dark" parent="android:Theme.Holo.Light.ActionBar"></style>

use getActionBar().getThemedContext() as the context for inflating your views. 使用getActionBar().getThemedContext()作为扩大视图的上下文。

You can use Holoeverywhere library to achieve your result. 您可以使用Holoeverywhere库来实现您的结果。
HoloEveryWhere 哪里都有

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当设备可以在应用程序级别强制使用时,如何避免在我的应用程序中强制使用深色主题? - How to avoid forced dark theme in my app when devices can force it at app level? 如何在 WebView 中设置深色主题? - How can I set Dark Theme in WebView? 如何在 Android 上强制应用深色主题? - How do I force apply a dark theme on Android? 如何强制使 WebView 父级变暗以便我可以使用 WebSettingsCompat.FORCE_DARK_AUTO? - How do I force darken the WebView parent so that I can use WebSettingsCompat.FORCE_DARK_AUTO? 我可以强制特定布局在 Android 中使用暗模式吗? - Can I force a specific layout to use dark mode in Android? 如何使应用程序具有黑暗和明亮的主题? - How can I make an app dark and light theme? 如何用我的主题指定黑暗动作模式 - How to specify dark action mode with my theme 如何强制关闭 Jetpack Compose 的暗模式主题 - How to force close dark mode theme for Jetpack Compose 如何在Light Appcompat主题中使用来自黑暗主题的SearchView - How to use SearchView from dark theme in Light Appcompat theme 如何为我的slideDrawer设置主题,使其具有漂亮的黑条? - How do I theme my slidingDrawer so it have a nice dark bar?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM