views:

61

answers:

3

Hi, I have a multi-line EditText:

<EditText android:layout_gravity="center" android:id="@+id/txtMessage"
android:layout_height="wrap_content" android:layout_below="@+id/lblMessage"
android:layout_width="wrap_content" android:width="250dip"
android:text="" android:maxLength="760" android:lines="4"></EditText>

How do I vertically align the text to the top. Now the content is aligned to the middle. And I'd like to have the content aligned to the top like this: http://img28.imageshack.us/img28/3972/edittext.png

Is there a property to do that? Or any other way? I haven't been able to find it.

Thanks! :)

A: 

Try

android:gravity="top"
neutrino
Thanks! It worked...
BikeCurious
A: 

Try this: android:gravity="top"

 <EditText android:layout_gravity="center"  
              android:id="@+id/txtMessage"
              android:layout_height="wrap_content" 
              android:layout_below="@+id/lblMessage"
              android:layout_width="wrap_content" 
              android:width="250dip"
              android:text="hello" 
              android:maxLength="760"
   android:gravity="top"                       
              android:lines="4"></EditText>


so android:gravity="top" sets the text at the "Top" Position. You can also set different android:gravity attribute value such as center, bottom, center_vertical, left, right, center_horizontal, etc.

Enjoy !!

PM - Paresh Mayani
Worked great, thanks!
BikeCurious
A: 

Can we align our text line by line(I mean whatever the text we have selected that should be aligned instead of the whole text)

Regards

vani

vani