我的 Activity 以我的自定义主题为主题,但对于微调器,我选择使用 Appcompat v21 对其进行样式设置,但我得到了这个:
那么,如果有办法,如何将 Spinner 箭头更改为黑色或蓝色?
我发现这是一个类似的问题,但没有任何答案:https://stackoverflow.com/questions/28561105/add-custom-spinner-arrow 这是我的微调器:
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/spinner2"
android:layout_marginTop="10dp"
android:layout_centerInParent="true" />
我用它来设计微调器的样式:
<style name="MyTheme.SpinnerAppTheme" parent="Widget.AppCompat.Spinner">
</style>
这是我使用适配器的方式
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
getBaseContext(), R.array.listMedRes, android.R.layout.simple_spinner_item);
我只想给微调器设置主题,非常感谢
最佳答案
可能会迟到,但迟到总比不到好。回答你的问题:“有没有办法只在微调器中使用它?”。答案是肯定的,引用下面的代码。
将此代码添加到您的主题或样式文件中
<style name="customSpinnerTheme" parent="yourAppThemeThatUseAppCompat21">
<item name="colorControlNormal">#eaeaea</item>
<item name="colorControlActivated">#000000</item>
<item name="colorControlHighlight">#000000</item>
</style>
然后在使用微调器的 XML 中添加这一行
android:theme="@style/customSpinnerTheme"
例如
<Spinner
android:theme="@style/customSpinnerTheme"
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:spinnerMode="dialog" />
关于android - 更改微调器箭头,Appcompat v21,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30135258/