My spinner is defined like this and it seems android:divider="#66BC31" has no effect, i still get white divider:
我的spinner是这样定义的,看起来android:divider="#66BC31"没有效果,我还是得到白色divider:
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dip"
android:layout_marginBottom="15dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:textColor="#ffffff"
android:divider="#66BC31"
android:background="@drawable/spina" />
This is my code where i change my spinner font and select resource for dropdown:
这是我的代码,我改变了我的旋转字体,选择资源为下拉:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Roaming.this,
R.layout.roaming_spinner, data) {
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
Typeface externalFont = Typeface.createFromAsset(getAssets(),
"fonts/HelveticaNeueLTCom-Lt.ttf");
((TextView) v).setTypeface(externalFont);
return v;
}
public View getDropDownView(int position, View convertView,
ViewGroup parent) { // we need this so we can use custom
// font for spinner (open)
View v = super.getDropDownView(position, convertView, parent);
Typeface externalFont = Typeface.createFromAsset(getAssets(),
"fonts/HelveticaNeueLTCom-Lt.ttf");
((TextView) v).setTypeface(externalFont);
return v;
}
};
adapter.setDropDownViewResource(R.layout.roaming_spinner_row);
I also tried adding line android:divider="#66BC31" to roaming_spinner_row.xml and roaming_spinner.xml where text size and color for my closed and opened spinner are declared and again with no success.
我还尝试添加了line android:divider="#66BC31"到roaming_spinner_row。xml和roaming_spinner。文本大小和颜色为我关闭的和打开的spinner的xml被声明和再次没有成功。
2 个解决方案
#1
9
I finally found the answer, thanks to this link and some more research.
我终于找到了答案,多亏了这个链接和更多的研究。
What you have to do is define in your activity's theme
你要做的是在你的活动主题中定义
<item name="android:dropDownListViewStyle">@style/App.Style.Spinner</item>
and then create the proper style with
然后创建合适的样式
<style name="App.Style.Spinner" parent="@style/Widget.Sherlock.Light.ListView.DropDown">
<item name="android:dividerHeight">10dip</item>
<item name="android:divider">@drawable/mydivider</item>
</style>
#2
0
In the Spinner's documentation there is no reference to android:divider
.
在Spinner的文档中,没有提到android:divider。
#1
9
I finally found the answer, thanks to this link and some more research.
我终于找到了答案,多亏了这个链接和更多的研究。
What you have to do is define in your activity's theme
你要做的是在你的活动主题中定义
<item name="android:dropDownListViewStyle">@style/App.Style.Spinner</item>
and then create the proper style with
然后创建合适的样式
<style name="App.Style.Spinner" parent="@style/Widget.Sherlock.Light.ListView.DropDown">
<item name="android:dividerHeight">10dip</item>
<item name="android:divider">@drawable/mydivider</item>
</style>
#2
0
In the Spinner's documentation there is no reference to android:divider
.
在Spinner的文档中,没有提到android:divider。