如何在 Android 应用中设置全息黑暗主题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12707560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set the holo dark theme in a Android app?
提问by gurehbgui
How can I set the dark holo theme in my app? At this time I got this:
如何在我的应用中设置深色全息主题?这时我得到了这个:
<style name="AppTheme" parent="android:Theme.Holo.Light" />
But when I change it to:
但是当我将其更改为:
<style name="AppTheme" parent="android:Theme.Holo.Dark" />
I get an error error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Dark'.
我收到一个错误 error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Dark'.
How to solve the problem?
如何解决问题?
回答by Lars Werkman
change parent="android:Theme.Holo.Dark"
to parent="android:Theme.Holo"
更改parent="android:Theme.Holo.Dark"
为parent="android:Theme.Holo"
The holo dark theme is called Holo
全息黑暗主题称为 Holo
回答by Anup Cowkur
By default android will set Holo to the Dark theme. There is no theme called Holo.Dark, there's only Holo.Light, that's why you are getting the resource not found error.
默认情况下,android 会将 Holo 设置为 Dark 主题。没有名为 Holo.Dark 的主题,只有 Holo.Light,这就是您收到资源未找到错误的原因。
So just set it to:
所以只需将其设置为:
<style name="AppTheme" parent="android:Theme.Holo" />
回答by Peter Shannon
According the android.com, you only need to set it in the AndroidManifest.xml file:
根据android.com,你只需要在AndroidManifest.xml文件中设置即可:
http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme
http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme
Adding the theme attribute to your application element worked for me:
将主题属性添加到您的应用程序元素对我有用:
--AndroidManifest.xml--
--AndroidManifest.xml--
...
...
<application ...
<申请...
android:theme="@android:style/Theme.Holo"/>
...
</application>
</应用>
回答by nikoo28
In your application android manifest file, under the application tag you can try several of these themes.
在您的应用程序 android 清单文件中,在应用程序标签下,您可以尝试其中的几个主题。
Replace
代替
<application
android:theme="@style/AppTheme" >
with different themes defined by the android system. They can be like:-
具有由android系统定义的不同主题。它们可以是这样的:-
android:theme="@android:style/Theme.Black"
android:theme="@android:style/Theme.DeviceDefault"
android:theme="@android:style/Theme.DeviceDefault.Dialog"
android:theme="@android:style/Theme.Holo"
android:theme="@android:style/Theme.Translucent"
Each of these themes will have a different effect on your application like the DeviceDefault.Dialog will make your application look like a dialog box. You should try more of these. You can have a look from the android sdk or simply use auto complete in Eclipse IDE to explore the various available options.
这些主题中的每一个都会对您的应用程序产生不同的影响,例如 DeviceDefault.Dialog 将使您的应用程序看起来像一个对话框。你应该多尝试这些。您可以查看 android sdk 或简单地使用 Eclipse IDE 中的自动完成功能来探索各种可用选项。
A correct way to define your own theme would be to edit the styles.xml
file present in the resources folder of your application.
定义自己的主题的正确方法是编辑styles.xml
应用程序资源文件夹中的文件。