为 Android 应用程序设置 Holo 主题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10274015/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:05:42  来源:igfitidea点击:

Setting Holo theme for Android application

androidandroid-theme

提问by Derek Organ

I have a simple login screen with username and password.

我有一个带有用户名和密码的简单登录屏幕。

I'd like it to show the EditTextfields in the same way as you see in the Holo theme on Ice Cream Sandwich and Honeycomb.

我希望它以EditText与您在 Ice Cream Sandwich and Honeycomb 的 Holo 主题中看到的相同的方式显示字段。

In my manifest file I have

在我的清单文件中,我有

<application
   android:icon="@drawable/ic_launcher"
   android:label="@string/app_name" 
   android:theme="@android:style/Theme.Holo">

Shouldn't the text fields now look different e.g. have no top, left and right borders?

文本字段现在看起来不应该有所不同,例如没有顶部、左侧和右侧边框吗?

Mine seem to look the exact same. I'm sure I'm doing something very basically wrong but any suggestions welcome.

我的似乎看起来完全一样。我确定我做的事情基本上是错误的,但欢迎提出任何建议。

This is what I see in the emulator: Screen Shot 2012-04-23 at 03.08.16

这是我在模拟器中看到的: 屏幕截图 2012-04-23 at 03.08.16

I was expecting more like this: http://developer.android.com/design/building-blocks/text-fields.html

我期待更多这样的:http: //developer.android.com/design/building-blocks/text-fields.html

回答by Ahmad

The original Android Holo Theme is just for API Level 11+. But there is an open source project called HoloEverywhere.

原始的 Android Holo 主题仅适用于 API 级别 11+。但是有一个名为 HoloEverywhere 的开源项目。

Take a look at this. This should solve your Problems.

看看这个。这应该可以解决您的问题。

So if you refere it as an Library you can set your Theme like this:

因此,如果您将其称为库,则可以像这样设置主题:

android:theme=“@style/Theme.Holo
// or if you want to use the Holo light theme:
android:theme=“@style/Theme.Holo.Light

回答by The Holo Dev

Try doing it on a per-activity basis. That's how I've always done it. It looks to me like the theme is not taking effect at all in your screenshot. Theme.Holo is dark. The white theme is Theme.Holo.Light.

尝试在每个活动的基础上进行。我一直都是这样做的。在我看来,您的屏幕截图中的主题根本没有生效。Theme.Holo 是黑暗的。白色主题是 Theme.Holo.Light。

<activity
        android:name=".login"
        android:label="@string/login"
        android:noHistory="true"
        android:theme="@android:style/Theme.Holo.Light"/>

<activity
        android:name=".Preferences"
        android:theme="@android:style/Theme.Holo.Light" >

etc rather than in the app level

等而不是在应用程序级别

Also, to correct Ahmad, Holo is available from Honeycomb and on, or 11+.

此外,为了更正 Ahmad,Holo 可从 Honeycomb 和 11+ 获得。

回答by Aleq

Actually, Holo is available since API 11; it's just Theme.Holo.Light.DarkActionBarthat came in API level 14. There is no need for 15+.

实际上,Holo 从 API 11 开始就可用了;只是Theme.Holo.Light.DarkActionBarAPI 级别为 14。不需要 15+。

For older API Levels, HoloEverywhere, ActionBarSherlock, ViewPageIndicatorand such are neccessary, as mentioned by Ahmad as well.

对于较旧的 API 级别,HoloEverywhereActionBarSherlockViewPageIndicator等是必要的,正如 Ahmad 所提到的。