我想在单击微调器下拉列表项时更改颜色。 我一直在 themes.xml、styles.xml 和 attr.xml 中搜索,但我仍然可以找到必须设置哪个属性才能实现此目的。
在attr.xml中有
<attr name="spinnerDropDownItemStyle" format="reference" />
在themes.xml中默认有themes
<style name="Theme">
...
<item name="spinnerDropDownItemStyle">@android:style/Widget.DropDownItem.Spinner</item>
<item name="spinnerItemStyle">@android:style/Widget.TextView.SpinnerItem</item>
...
当我在 style.xml 中执行此操作时,我找不到分配背景可绘制对象(带有用于按下和聚焦的选择器)的任何条目(我想一定有某个地方引用了 xml 文件里面有选择器,比如按钮)。
简而言之:我找不到必须设置的内容才能更改微调器下拉项的点击和焦点外观。
可以单独更改背景
<style name="CustomSpinnerAppearance0" parent="android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/spinner_default0</item>
<item name="android:dropDownSelector">#ffc0c0c0</item>
<item name="android:popupBackground">#ffc0c0c0</item>
</style>
但即使我将选择器或过渡设置为 popupBackground,点击行为也没有任何变化。
有什么想法吗?
谢谢。
最佳答案
与此同时,我找到了解决方案。
要结束这个问题: 我仍然不知道,为什么它在我设置 dropDownSelector 时对行为没有影响。
但是改变属性
<item name="android:listChoiceBackgroundIndicator"></item>
成功了。
关于android - 必须为微调器下拉项更改什么样式属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8782382/