eclipse Android 主题设置为黑色,但在 Android 4.1 中为白色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12277315/
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
Android theme set to black, but it is white in Android 4.1
提问by noelicus
I have tried both Theme.DeviceDefault
and Theme.Black
in my styles.xml, and both make my 2.1 emulator become black correctly, but on the 4.1 emulator it stays white...am I doing something wrong?
我曾经尝试都Theme.DeviceDefault
和Theme.Black
我的styles.xml,都让我的2.1模拟器变成黑色正确的,但在4.1模拟器它停留白色......我做错了什么?
<resources>
<style name="AppTheme" parent="android:Theme.Black" />
</resources>
PS: I presume the drop-down for "Theme" at the top of the Graphical Layout is just showing me what it would look like, it's not some kind of setting that's going somewhere (for the app)?
PS:我认为图形布局顶部的“主题”下拉菜单只是向我展示了它的样子,这不是某种设置(对于应用程序)?
回答by Matt Handy
The Android system always chooses the most special values folder that fits best to your device.
Android 系统始终选择最适合您的设备的最特殊的值文件夹。
As example if you have a folder values
and another folder values-v14
the Android system takes resources from the latter if the device is v14 or newer.
例如,如果您有一个文件夹values
和另一个文件夹values-v14
,如果设备是 v14 或更新版本,Android 系统将从后者获取资源。
Please refer to the Android documentationfor more information.
有关更多信息,请参阅Android 文档。
回答by Tomer Mor
1.create new folder under res -> values-v13
2.create file style there and add this style :<style name="AppTheme" parent="android:style/Theme.Holo.Light">
1. 在 res -> values-v13 下创建新文件夹 2. 在
那里创建文件样式并添加此样式:<style name="AppTheme" parent="android:style/Theme.Holo.Light">
in your manifast use this style for your application like this
在您的清单中,将这种风格用于您的应用程序
<application
android:name=".MainApp"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
that way on ICS version you use the Holo.light theme and pre ICS use the default you already created
这样在 ICS 版本上,您使用 Holo.light 主题,而 pre ICS 使用您已经创建的默认值
回答by Anfet
Setting it via styles doesn't actually work, but if you set it explicitly for application it works.
通过样式设置它实际上不起作用,但是如果您为应用程序明确设置它,它就可以工作。
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black" >
回答by Anfet
By default 4.0 and 4.1 give us white background but you can change it to black I face the same problem some days ago, if your project theme is set to be black then probably you change the Title while creating project to "Main" by default its "MainActivity" but if you change it to "Main" it will give you black backgrount/
默认情况下,4.0 和 4.1 为我们提供白色背景,但您可以将其更改为黑色我几天前遇到了同样的问题,如果您的项目主题设置为黑色,那么您可能在创建项目时将标题更改为默认情况下的“主要” “MainActivity”但如果你把它改成“Main”,它会给你黑色背景/
I don't know my answer is relevant to your question or not but i think you talking about this if i am not wrong.
我不知道我的回答是否与您的问题相关,但如果我没有错,我认为您在谈论这个。