如何在不使用 textview 的情况下更改微调器中的文本颜色
How to change text color in spinner without using textview
我想在不使用 textView
的情况下更改微调器 的文本颜色,我已经搜索并找到了一些教程 Android: Where is the Spinner widget's text color attribute hiding?
但最主要的是他们已经使用了textView
。
<Spinner
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:entries="@array/Gender_Selection_arrays"
android:prompt="@string/Gender_Selection"
android:id="@+id/gendersel"
android:popupBackground="#67656c"/>
我知道这段代码不是用来改变文字颜色的。
我不知道该怎么做,请指导我这样做。
任何帮助将不胜感激。
你的微调器
<Spinner
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:entries="@array/Gender_Selection_arrays"
android:prompt="@string/Gender_Selection"
android:id="@+id/gendersel"
style="@style/mySpinnerItemStyle"
android:popupBackground="#67656c"/>
mySpinnerItemStyle(将此添加到 styles.xml)
<style name="mySpinnerItemStyle" parent="Base.Widget.AppCompat.Spinner">
<item name="android:textColor">@color/my_spinner_text_color</item>
</style>
最后在 colors.xml
<color name="my_spinner_text_color">#FFFFFF</color>
mySpinnerItemStyle 继承自 Base.Widget.AppCompat.Spinner 并且 android:textColor 属性更改微调器文本的颜色
我找到了解决方案,创建一个新的 xml "spinner_style.xml"
<?xml version="1.0" encoding="UTF-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/Black" />
并在 activity:
中将此布局固定为微调器样式
ArrayAdapter<String > gender_adapter = new ArrayAdapter<String> (getActivity(), R.layout.spinner_style,gender_spinner );
我想在不使用 textView
的情况下更改微调器 的文本颜色,我已经搜索并找到了一些教程 Android: Where is the Spinner widget's text color attribute hiding?
但最主要的是他们已经使用了textView
。
<Spinner
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:entries="@array/Gender_Selection_arrays"
android:prompt="@string/Gender_Selection"
android:id="@+id/gendersel"
android:popupBackground="#67656c"/>
我知道这段代码不是用来改变文字颜色的。
我不知道该怎么做,请指导我这样做。
任何帮助将不胜感激。
你的微调器
<Spinner
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:entries="@array/Gender_Selection_arrays"
android:prompt="@string/Gender_Selection"
android:id="@+id/gendersel"
style="@style/mySpinnerItemStyle"
android:popupBackground="#67656c"/>
mySpinnerItemStyle(将此添加到 styles.xml)
<style name="mySpinnerItemStyle" parent="Base.Widget.AppCompat.Spinner">
<item name="android:textColor">@color/my_spinner_text_color</item>
</style>
最后在 colors.xml
<color name="my_spinner_text_color">#FFFFFF</color>
mySpinnerItemStyle 继承自 Base.Widget.AppCompat.Spinner 并且 android:textColor 属性更改微调器文本的颜色
我找到了解决方案,创建一个新的 xml "spinner_style.xml"
<?xml version="1.0" encoding="UTF-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/Black" />
并在 activity:
中将此布局固定为微调器样式 ArrayAdapter<String > gender_adapter = new ArrayAdapter<String> (getActivity(), R.layout.spinner_style,gender_spinner );