I would like to align a textview (saying : "Day :") with a Spinner where the user can choose the day of the week he wants (Monday, Tuesday, etc.)
when I try to align them :
<TextView android:id="@+id/labelSpinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/textSpinner1"
android:layout_toRightOf="@+id/spinner_days"
android:layout_alignParentTop="true"/>
<Spinner android:id="@+id/spinner_days"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/labelSpinner1"
android:layout_alignParentLeft="true"
android:drawSelectorOnTop="true"/>
the result I get is that I only see the Spinner, and the TextView isn't showing (or is underneath the Spinner)
Thank you for your help!
I guess you want the Spinner to the right of the TextView? Check the following code:
<TextView
android:id="@+id/labelSpinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="@string/textSpinner1" />
<Spinner
android:id="@+id/spinner_days"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/labelSpinner1"
android:layout_toRightOf="@id/labelSpinner1"
android:drawSelectorOnTop="true" />
Your problem was that the spinner filled the whole view (android:layout_width="fill_parent"
) while you forced the TextView to be right of the Spinner (so outside of the screen --> invisible for you)
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