Styling a Spinner, appcompat, material

蹲街弑〆低调 提交于 2019-12-08 17:42:18

问题


So my app theme extends from AppCompat's Material Light theme with Dark Action Bar.

I applied an accent color.

Now I am trying to use a Spinner on a dark backround and because of the theme, the spinner has a dark gray arrow which changes to accent color when pressed.

How can I make this spinner's arrow white so that it is prominent on a dark background?

Here's the image of the Spinner:


回答1:


If you want to apply same spinner style app wide, then in your values/styles.xml, override spinnerStyle with your custom style, which derives from an appcompat type and override android:background:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="android:spinnerStyle">@style/AppSpinner</item>
</style>

<style name="AppSpinner" parent="Widget.AppCompat.Spinner">
    <item name="android:background">@drawable/your_spinner_background</item>
</style>

If you need a quick way to generate a spinner background, try android-holo-colors, choose Colored Spinner and supply your accent color.




回答2:


So the support library 22.1 enables use of android:theme attribute on views. That should help here.




回答3:


with android:background you can specify your own background resource. I find the arrow rather useless (tapping the spinner brings dropdown menu even without arrow) so if you don't want to draw a custom arrow image, just leave the background black or transparent.



来源:https://stackoverflow.com/questions/28079903/styling-a-spinner-appcompat-material

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