更改微调文本颜色

mus*_*igh 3 android xamarin.android android-spinner xamarin xamarin.forms

我想将Spinner 中的默认文本颜色更改为任何其他颜色。但我还没有找到解决方案。我通过TextView得到了一个解决方案,例如 如何更改微调器文本大小和文本颜色?
Spinner 有没有其他直接的方法?

注意:请提供 Xamarin 的解决方案。谢谢你。

小智 18

仅针对选定的项目颜色更改尝试这样:

spinnerObject.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
    ((TextView)parentView.getChildAt(0)).setTextColor(Color.RED);
}
});
Run Code Online (Sandbox Code Playgroud)

其它的办法:

<style name="spinnerTheme">
<item name="android:textColor">@color/gray_dark</item>
</style>

<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="50dp"
android:theme="@style/spinnerTheme"/>
Run Code Online (Sandbox Code Playgroud)