Gingerbread devices not using Holo style from Theme.AppCompat (support library)

戏子无情 提交于 2019-12-23 09:38:11

问题


I'm using the v4 and v7 support library to integrate the action bar and navigation drawer in my app, which supports API 10+.

I've followed the guide on the developer site to use Theme.AppCompat and style/Widget.AppCompat.ActionBar as the parent of my theme and action bar style, respectively.

Everything works fine, except when I test on Gingerbread devices, things like a dropdown/popup menu has a white background (skin from the phone) and text fields don't use the holo-style backgrounds (again, uses the phone skin).

Is there anything extra I need to do so pre-Holo devices inherit the holo-style widgets?

Thanks in advance.


回答1:


Regardless of using the support library, widgets such as TextView, Spinner, CheckBox, Button, Switch etc. will not look Holo styled automatically.

What the support library lets you do is use some profoundly important UI elements and APIs that are not available on versions of Android before Honeycomb (like the ActionBar), but the style of the widgets will remain distinctly the same as it is for the API level the phone is actually running.

You have a few options here:

1.) Scavenge resources from one of the API >= 14 platforms/ subdirectories of your android SDK installation and copy/adjust the drawables and styles for the widgets you want to change yourself. However this is something I don't recommend at all, because it will be a long and arduous task if you are using many different widgets that need this kind of adjustment.

2.) Use Android Holo Colors, which is an online generator for Holo compliant resources and supports almost all of the widgets right away: http://android-holo-colors.com/ Just pick your preferred color, the API version you want to support and the widgets you want to adapt to Holo. Holo Colors will generate an archive containing all the drawables and style definitions for you. The drawables you can pretty much copy into your project straight away, the styles you'll probably have to integrate into your existing styles.xml

3.) There is a library, called HoloEverywhere (https://github.com/Prototik/HoloEverywhere), which already has most widgets adapted to Holo, but you'll need to extend their custom activity class and directly reference their adapted widgets classes.

Hope this helps!



来源:https://stackoverflow.com/questions/19968678/gingerbread-devices-not-using-holo-style-from-theme-appcompat-support-library

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