Android - 如何更改微调器本身的颜色?
问题描述:
我所有的搜索引导我指导如何更改微调器选项的文本颜色,但是如何更改微调器本身上的文本和箭头的颜色?Android - 如何更改微调器本身的颜色?
这里是我的飞旋剪断。它应该说“水星”。
这是我对风格的尝试。它确实将箭头更改为白色,但不是文本。我只将它应用于微调器,因为它会弄乱其余的活动。
<style name="Theme.LightText2" parent="AppTheme">
<item name="android:editTextColor">#ffffff</item>
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:textColorSecondary">#ffffff</item>
<item name="android:textColorTertiary">#ffffff</item>
<item name="android:textColorPrimaryInverse">#ffffff</item>
<item name="android:textColorSecondaryInverse">#ffffff</item>
<item name="android:textColorTertiaryInverse">#ffffff</item>
</style>
更新:我试图通过清单将它应用到活动本身,它工作,但它是我的其余活动搞砸了。
答
如果你想做到这一点,做一件事情,采取一个文本视图,并在右侧设置箭头图标(Drawableright)自定义文本文本视图,并单击打开对话框单选和项目选择设置文本到textview
答
创建阵列适配器将膨胀TextView
从Layout_resource
那么你的颜色设置为充气TextView
your_spinnersp.setAdapter(new ArrayAdapter<>(context,R.layout.txt_spinner,lst_data));
在布局添加的TextView
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="8dp" android:textSize="16sp"
android:background="#ff0000"
android :textColor="#ffff00"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
答
尝试像这样并使用spnrSelect.performClick();点击rlSpinner打开spinner
<RelativeLayout
android:id="@+id/rlSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/scale_20dp"
android:layout_marginRight="@dimen/scale_20dp"
android:layout_marginTop="@dimen/scale_1dp"
android:background="@null"
android:clickable="true">
<Spinner
android:id="@+id/spnrSelect"
android:layout_width="match_parent"
android:layout_height="0dp"
android:clickable="true"
android:dropDownWidth="@dimen/scale_300dp"
android:scrollbars="none"
android:spinnerMode="dropdown" />
<TextView
android:id="@+id/txtSelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingBottom="@dimen/scale_1dp"
android:paddingRight="@dimen/scale_1dp"
android:paddingTop="@dimen/scale_1dp"
android:text="@string/txtSelect"
android:textColor="@color/edt_hint"
android:textColorHint="@color/edt_hint"
android:textSize="@dimen/txt_12" />
<ImageView
android:id="@+id/spnrDownArrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/scale_10dp"
android:background="@drawable/arrow_icon"
android:rotation="90" />
</RelativeLayout>
检查此问题http://*.com/questions/12599703/custom-spinner-adapter – Bharatesh