更改微调器文本字体的颜色
To change the color of the spinner text font
我看到了这个link:https://docs.microsoft.com/en-us/xamarin/android/user-interface/controls/spinner
我想更改微调器文本字体的颜色:
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:textColor="#FF0080FF"
android:popupBackground="#FF553232"
android:background="#FFD733D7"/>
但在输出中,文本颜色始终为白色。
选项 1. 将您的自定义主题添加到 style.xml。这将更改下拉列表中项目的文本颜色。
<style name="MySpinnerTheme" parent="android:Theme">
<item name="android:textColor">@android:color/holo_green_dark</item>
</style>
布局
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MySpinnerTheme"
android:spinnerMode="dropdown"/>
选项2。如果您只想更改所选项目。
...
Spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
...
private void spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e){
Spinner spinner = (Spinner)sender;
TextView textView = (TextView)spinner.SelectedView;
textView.SetTextColor(Color.Rgb(0, 235, 0));
}
我看到了这个link:https://docs.microsoft.com/en-us/xamarin/android/user-interface/controls/spinner
我想更改微调器文本字体的颜色:
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:textColor="#FF0080FF"
android:popupBackground="#FF553232"
android:background="#FFD733D7"/>
但在输出中,文本颜色始终为白色。
选项 1. 将您的自定义主题添加到 style.xml。这将更改下拉列表中项目的文本颜色。
<style name="MySpinnerTheme" parent="android:Theme">
<item name="android:textColor">@android:color/holo_green_dark</item>
</style>
布局
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MySpinnerTheme"
android:spinnerMode="dropdown"/>
选项2。如果您只想更改所选项目。
...
Spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
...
private void spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e){
Spinner spinner = (Spinner)sender;
TextView textView = (TextView)spinner.SelectedView;
textView.SetTextColor(Color.Rgb(0, 235, 0));
}