views:

76

answers:

2

Hello everybody, I've noticed that layout_alignBaseline of TextVew control doesn't work with Spinner control. I'm trying to place a text to the left of spinner, but it goes 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 it a bug or I do something wrong? The same technique works fine with EditText controls.

A: 

android:layout_toLeftOf="@id/locations" ?

Alex Volovoy
Can't post images unfortunately. Well it didn't help, but thanks.To be more clear I have 2 RelativeLayouts inside each other. <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> </RelativeLayout> </RelativeLayout>The fist one is a parent, second one is a child that is placed in the center of a screen. Spinner is paced okay, but TextViev goes to the top of child layout. They are both in the child layout. Solved it using margin.
Maxim
A: 

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"/>
Ashis Pradhan