I am customizing spinner in Android / Xamarin project. It's set to SimpleSpinnerDropDownItem. I would like to add icon which is with selected / default item. What I've already did with style is Spinner background (it's white and rounded), also there is style for background in drop down list.
Spinner implementation
Spinner spinner = FindViewById<Spinner>(Resource.Id.spinner);
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
var adapter = ArrayAdapter.CreateFromResource(
this, Resource.Array.organisation_array, Android.Resource.Layout.SimpleSpinnerItem);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.SetSelection(1);
spinner.Adapter = adapter;
XML in Activity
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spinner"
android:background="@drawable/rounded_shape"
style="@style/DropDownSpinner.My"
android:minHeight="50dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" />
XML Styles
<style name="DropDownSpinner.My" parent="@android:style/Widget.Holo.Light.Spinner">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_spinner</item>
</style>
No comments:
Post a Comment