我在activity 中创建了一个spinner,当在JellyBean(4.1)设备上运行程序时, spinner看起来像是2.x的主题,如何设置成ICS(4.0)的样子 ?
这是spinner代码:
<Spinner
android:id="@+id/spinnermap"
style="@android:style/Theme.Holo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
正如代码中所体现的,我把全局style设置成 "Holo",但是没有结果。在numberPicker 上也遇见了同样的问题,不知道如何解决。
style="@android:style/Theme.Holo"
这个不是解决方法,你不需要在pre HC设备上备份。如果你想在 HC+(假设你用的这个)的整个应用使用holo主题,你应该为整个应用程序申明一个主题。
在Manifest中:
android:theme="@style/MyTheme"
values/styles.xml:
<style name="MyTheme" parent="android:Theme.Light">
</style>
values-v11/styles.xml:
<style name="MyTheme" parent="android:Theme.Holo.Light">
</style>
现在在 HC+ 上有一个dropdown spinner。
如果你只是想让spinner被"holofied",可以这样:
<Spinner
android:id="@+id/spinnermap"
style="@style/MySpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
values/styles.xml:
<style name="MySpinner" parent="android:Widget.Spinner">
</style>
values-v11/styles.xml:
<style name="MySpinner" parent="android:Widget.Holo.Spinner">
</style>
你的主题是不是应该写成 ThemeHolo,而不是Theme.Holo, 直接写在布局文件的这种没试验过,
写在manifest.xml对应的activity的属性里 类似这样 `android:theme = @style/ThemeHolo, 我试过是可以设置成功的。
好文章!解决了困扰我已久的spinner系统样式问题,android4.0以后的spinner,样子真难看