[英]Change the divider color of Spinner
由于我的弹出背景为白色,因此我需要更改微调框分隔线的颜色。 我曾尝试通过以下方式设置微调器的样式,但无法正常工作:
styles.xml
<style name="applicationTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:dropDownListViewStyle">@style/SpinnerStyle</item>
</style>
<style name="SpinnerStyle" parent="android:Widget.ListView.DropDown">
<item name="android:divider">#0193DE</item>
<item name="android:dividerHeight">1dp</item>
</style>
主xml
<Spinner
android:id="@+id/year"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:background="@drawable/apptheme_spinner_default_holo_dark"
android:layout_marginLeft="75dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:spinnerMode="dropdown"
style="@style/SpinnerStyle"
android:popupBackground="#FFFFFF" />
爪哇
ArrayAdapter<Integer> adapter_year = new ArrayAdapter<Integer>(this, R.drawable.custom_spinner_holidays, year);
adapter_year.setDropDownViewResource(R.layout.custom_spinner_popup);
custom_spinner_holidays.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@android:color/white" />
custom_spinner_popup
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="marquee"
android:singleLine="true"
android:textColor="#0193DE" />
我可以将所有这些组合成一个吗?
您需要像下面这样将该主题放入清单文件中:
<activity android:name="com.example.activity.Solution"
android:theme="@style/applicationTheme">
</activity>
也许最好的办法是使用自己的微调器,您可以按照自己的方式设置样式。 看看下一个线程对我来说是如此有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.