简体   繁体   English

为Android应用程序设置Holo主题

[英]Setting Holo theme for Android application

I have a simple login screen with username and password. 我有一个简单的登录界面,包含用户名和密码。

I'd like it to show the EditText fields in the same way as you see in the Holo theme on Ice Cream Sandwich and Honeycomb. 我希望它以与您在冰淇淋三明治和蜂窝中的Holo主题中看到的相同的方式显示EditText字段。

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 eg 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: 这是我在模拟器中看到的: 屏幕截图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

The original Android Holo Theme is just for API Level 11+. 最初的Android Holo Theme仅适用于API Level 11+。 But there is an open source project called HoloEverywhere. 但是有一个名为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

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. Theme.Holo很黑。 The white theme is Theme.Holo.Light. 白色主题是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岁以上购买。

Actually, Holo is available since API 11; 实际上,Holo自API 11起可用; it's just Theme.Holo.Light.DarkActionBar that came in API level 14. There is no need for 15+. 它只是在API级别14中出现的Theme.Holo.Light.DarkActionBar 。不需要15+。

For older API Levels, HoloEverywhere , ActionBarSherlock , ViewPageIndicator and such are neccessary, as mentioned by Ahmad as well. 对于较旧的API级别, HoloEverywhereActionBarSherlockViewPageIndicator等都是必要的,正如Ahmad所提到的那样。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM