Android 去除微调器上的压色
我想删除单击微调器时出现的蓝色(我正在用Holo测试我的应用程序) 我的代码:Android 去除微调器上的压色,android,colors,spinner,pressed,Android,Colors,Spinner,Pressed,我想删除单击微调器时出现的蓝色(我正在用Holo测试我的应用程序) 我的代码: ArrayAdapter<String> array_adapter = new ArrayAdapter<String> (getActivity(), R.layout.spinner_item, string_array); array_adapter.setDropDownViewResource(R.layout.spinner_item);
ArrayAdapter<String> array_adapter = new ArrayAdapter<String> (getActivity(),
R.layout.spinner_item, string_array);
array_adapter.setDropDownViewResource(R.layout.spinner_item);
Spinner spinner = (Spinner) getView().findViewById(R.id.spinner);
spinner.setAdapter(array_adapter);
ArrayAdapter array\u adapter=新的ArrayAdapter(getActivity(),
R.layout.spinner_项,字符串_数组);
array_adapter.setDropDownViewResource(R.layout.spinner_项);
微调器微调器=(微调器)getView().findViewById(R.id.Spinner);
spinner.setAdapter(数组_适配器);
spinner_item.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinner_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:background="@drawable/item"
style="@style/EquidiaTheme.MySpinner" />
和item.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@android:color/transparent" />
<item android:state_selected="true" android:drawable="@android:color/transparent" />
<item android:drawable="@android:color/transparent" />
</selector>
这不管用。有什么想法吗?定制
android:spinnerDropDownItemStyle
当我选择该项目时,我能够去掉该项目上的蓝色矩形,当我这样做时: 首先,我声明要在values.xml中使用的颜色:
<resources>
<drawable name="red_color">#ff0000</drawable>
<drawable name="blue_color">#0000ff</drawable>
<drawable name="green_color">#00ff00</drawable>
<drawable name="transparent_color">#00000000</drawable>
</resources>
但对于android来说,它应该是:
还要去除微调器本身上的蓝色矩形,请使用:
<Spinner
android:background="@null"
没有主题的解决方案。如果你只有几个纺纱机就很理想了
创建状态为()的可绘制(xml)
对按下状态和正常状态使用相同的图像
然后将其用作背景:
mySpinner.setBackgroundResource(R.drawable.my_spinner_state_drawable)
额外提示:
- 您可以从系统资源中使用系统可绘制(图像):如“@android:drawable/btn\u dropdown\u normal”。它更易于维护,给人一种更自然的外观和感觉
- 参考号
我不知道。我希望选中/按下该项时该项完全不显示颜色。
<Spinner
android:background="@null"
<item name="android:attr/colorPressedHighlight">#FF0000</item>
<item name="android:attr/colorLongPressedHighlight">#FF0000</item>
<item name="android:attr/listChoiceIndicatorSingle">@drawable/red_color</item>
mySpinner.setBackgroundResource(R.drawable.my_spinner_state_drawable)