Android: Theme Holo previous version

你说的曾经没有我的故事 提交于 2019-12-29 14:56:14

问题


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

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?

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

Thanks!


回答1:


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:

  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>
    

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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/9830916/android-theme-holo-previous-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!