Java Android: Theme Holo 以前的版本

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

Android: Theme Holo previous version

javaandroidstylesthemes

提问by Pew Labs

I really like the 4.0 ICS Holo Light theme and would like to have it in my app to support <4.0 smartphones.

我真的很喜欢 4.0 ICS Holo Light 主题,并希望在我的应用程序中使用它来支持 <4.0 智能手机。

I found Android layoutlib.jar in platform folder but its 8mb!!! and I really don't have afford to increase my app with 8mb. Any tip?

我在平台文件夹中找到了 Android layoutlib.jar 但它有 8mb !!!而且我真的负担不起用 8mb 增加我的应用程序。任何提示?

//Pew Labs PS ive tried https://github.com/ChristopheVersieux/HoloEverywherebut it doesnt support TabVIew which I use

//Pew Labs PS 我试过https://github.com/ChristopheVersieux/HoloEverywhere但它不支持我使用的 TabVIew

Thanks!

谢谢!

采纳答案by Nick

It would be better not to use the Holo theme on unsupported devices. You can do a simple trick to make your app run the Holo theme on 3.x and up, and one of the built in themes on 2.3 and below, like so:

最好不要在不受支持的设备上使用 Holo 主题。您可以通过一个简单的技巧让您的应用在 3.x 及更高版本上运行 Holo 主题,并在 2.3 及以下版本上运行内置主题之一,如下所示:

  1. In your manifest, use this line for your activity's theme

    android:theme="@style/Theme.MyTheme"

  2. In your res/values folder put a styles.xml file, containing

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
      <style name="Theme.MyTheme" parent="@android:style/Theme.Black" />
    </resources>
    
  3. Create a res/values-v11 folder, and a styles.xml file in that, containing:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
      <style name="Theme.MyTheme" parent="@android:style/Theme.Holo" />
    </resources>
    
  1. 在您的清单中,将此行用于您的活动主题

    android:theme="@style/Theme.MyTheme"

  2. 在您的 res/values 文件夹中放置一个 style.xml 文件,其中包含

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
      <style name="Theme.MyTheme" parent="@android:style/Theme.Black" />
    </resources>
    
  3. 创建 res/values-v11 文件夹,并在其中创建一个 style.xml 文件,其中包含:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
      <style name="Theme.MyTheme" parent="@android:style/Theme.Holo" />
    </resources>
    

This will make Android use the Holo theme if the app is running on a device that supports it (3.x and up, which is API level 11 and up, hence the "values-v11"). This is the best solution to make your app match the phone's user interface, and use the Holo theme only wherever it's supported.

如果应用程序在支持 Holo 主题的设备上运行(3.x 及更高版本,即 API 级别 11 及更高版本,因此为“values-v11”),这将使 Android 使用 Holo 主题。这是使您的应用程序与手机的用户界面相匹配的最佳解决方案,并且仅在支持的地方使用 Holo 主题。

回答by theomega

Check ActionbarSherlock. It also provides a styled TabView. The samples directory provides a real good example for a TabView which works like a charm on Android 2.2.

检查ActionbarSherlock。它还提供了一个样式化的 TabView。示例目录为 TabView 提供了一个真正的好例子,它在 Android 2.2 上就像一个魅力。

回答by Ahmad

You can use Holo in Android 2.3< with this simple library : http://www.holoeverywhere.com/Its called Holo everywhere and works fine in previous versions of android. The Library is hosted on Github.

您可以使用这个简单的库在 Android 2.3< 中使用 Holo:http: //www.holoeverywhere.com/它在任何地方都称为 Holo,并且在以前的 android 版本中运行良好。图书馆托管在Github 上