问题
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