I want to show spinner with static small label above it how it can be possible seen one of the popular app want to show same like it.
Here is my image, red marked one is the spinner with gray colored text above it which does not changes
I don't want to show android:prompt
which shows default text inside spinner
want to show exact above the spinner in same control
That title is nothing but a TextView.
for this you will have to create custom spinner:
layout of spinner according to your need name it as custom_spinner
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tVStaticSmallLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="static text"
android:textColor="#777777"
android:textSize="22px" />
<TextView
android:id="@+id/tVMainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tVStaticSmallLabel"
android:layout_marginTop="5dip"
android:text="your changing text" />
</RelativeLayout>
in activity give this layout to the spinner:
Spinner mySpinner = (Spinner) findViewById(R.id.yourSpinner);
mySpinner.setAdapter(new MyAdapter(this, R.layout.custom_spinner,
spinnerValues));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With