how to change android spinner popupBackground -



how to change android spinner popupBackground -

i trying alter android spinner popup window background setting android:popupbackground, didn't have effect. there way can alter it?

<spinner android:id="@+id/eventnamespinner" android:layout_width="160dp" android:layout_height="30dp" android:layout_alignparentleft="true" android:layout_centervertical="true" android:layout_marginleft="6dp" android:background="@drawable/btn_name" android:paddingbottom="2dp" android:paddingtop="2dp" android:popupbackground="@drawable/bkg">

i presume trying alter "outer" backgroud of spinner's popup, not background of spinner "pupup items". also, presume popup, mean spinner's dialog mode, floating dialog window appears on top of activity, opposed new dropdown mode.

strategy

for clean, sustainable approach behaves across multiple android platforms , reduces need redundancy in app, believe essential understand official docs don't tell us. follow me on short journey.

the tricky part spinners adapter used connect them data. while relatively easy identify hooks changing appearance of android.r.layout.simple_spinner_item , friends, determine style of spinner's displayed item each single popup item. adapter responsible creating listview , other widgets frame listview.

this complexity reason why android has introduced attributes can specified on-the-fly "for" spinner although applied spnner's children, such android:popupbackground. not clean approach, rather limited set of convenience functions. regarding popupbackground, btw, introduced in api level 1, spinners respect in spinnermode=dropdown, introduced in api level 11. that's reason why you'll never notified if utilize wrongly.

older android versions (such 2.2) listview

knowing adapter creates listview, it's not bad thought alter listview appearance in one's theme, there's 1 single place design alter , styling straightforward, so:

<style name="mytheme" parent="@android:style/[reference original theme]" > <item name="android:listviewstyle">@style/mylistview</item> [...] </style> <style name="mylistview" parent="@android:style/widget.listview"> [check android's widget.listview understand can alter here] </style> alertdialog

unfortunately, there's more work ahead. because android:prompt can used create headline popup, popup consists of more listview.

android uses alertdialog

recent android versions (such 4.2)

now alertdialogs styled, still have address fact more recent versions of android don't utilize alertdialogs spinner dialogs more. doesn't hurt, because those, alertdialog style shouldd kept anyways. means need style new popup well.

to so, create version specific theme xml files pull additional styles customized theme, , provide version specific style xml files.

feel trying yourself, starting here?

android android-widget android-spinner

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -