What property controls Spinner dropdown background?

混江龙づ霸主 提交于 2020-01-03 17:30:33

问题


I have a custom theme created with this generator. It has a custom style for Spinners which I don't like. I want to change the background drawable but I can't seem to figure out which property controls this.

This is what the themed version looks like

And here is what it will look like when using the Holo.Light theme.

Notice the dark gray lines around the dropdown list in the first (themed) image. This is what I want to get rid of. What property controls this? I want them to match the default.

Also, what controls the vertical aligment of the dropdown list? As you can see, it is overlapping with the Spinner in the first image (the line under it isn't visible as it is in the second image).


回答1:


The attribute you want is android:popupBackground on the Spinner element.

If you look closely, the holo popup also overlaps the spinner some, but there is a bunch of padding for the drop shadow, so it looks good.

However, you can use android:dropDownVerticalOffset on the Spinner element to adjust it.




回答2:


We came across the same issue. It has to do with the Android Holo theme generator.

Here are the lines that you should remove from your Theme.xml file...

<item name="android:spinnerStyle">@style/SpinnerCustom</item>
<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItemCustom</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Custom</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Custom</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Custom</item>

...by removing these, we now have the standard Holo.Light theme on the spinner dropdowns.




回答3:


You need to change the parent of spinnertheme to android:Widget.Holo.Light.Spinner

<style name="SpinnerTHEME" parent="android:Widget.Holo.Light.Spinner">



回答4:


<style name="spinner_style" parent="android:Widget.Holo.Light.Spinner">
       <item name="android:paddingLeft">@dimen/ten_dp</item>
       <item name="android:paddingRight">@dimen/ten_dp</item>
</style>


来源:https://stackoverflow.com/questions/20423391/what-property-controls-spinner-dropdown-background

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