Use layout_alignBaseline with Spinner
I noticed that the layout_alignBaseline of the TextVew control does not work with the Spinner control. I'm trying to position the text to the left of the spinner, but it will move to the top of the parent control.
<Spinner
android:id="@+id/locations"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/userCode"
android:layout_alignLeft="@id/userCode"
android:layout_marginTop="15dip"
/>
<TextView
android:id="@+id/locationsLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Region"
android:layout_alignBaseline="@id/locations"
/>
Is this a bug or am I doing something wrong? The same technique works great with EditText controls.
a source to share
I am also facing the same problem but found the following workaround
<Spinner
android:id="@+id/locations"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/userCode"
android:layout_alignLeft="@id/userCode"
android:layout_marginTop="15dip"/>
<TextView
android:id="@+id/locationsLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Region"
android:layout_alignTop="@+id/locations"
android:layout_alignBottom="@+id/locations"
android:gravity="center_vertical"/>
a source to share
New versions of Android baseline support for Spinners. The Spinner will create the first view of the list and use its baseline alignment.
If that doesn't work, make sure your spinner adapter creates a View that supports baseline alignment. (getBaseline ()! = -1). For LinearLayouts, you can use the baselineAlignedChildIndex attribute to specify a child in the line layout to use.
a source to share