57

I have an EditText with the property:

android:minLines="3"

However, when I start typing, it types in the middle of the EditText.

Is there any way to get this to start typing at the top left of the EditText area?

CaptJak
  • 3,592
  • 1
  • 29
  • 50
NotACleverMan
  • 12,107
  • 12
  • 47
  • 67

4 Answers4

183

Add android:gravity="top|left" to the EditText in the layout XML file.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @Commons Ware what should i need to do if i want my edittext hint in center_vertical but it should start typing from top|left ? – Erum Aug 26 '15 at 13:03
  • @Erum: I am not aware of a way to control the positioning of the hint independently of the positioning of the text. – CommonsWare Aug 26 '15 at 13:05
  • 5
    Use start or end rather than left and right these days to compensate for both RTL and LTR readers – Andre L Torres Feb 28 '18 at 18:40
4

Just insert

android:gravity="top"

into your EditText.

Mainly Karma
  • 437
  • 2
  • 12
4

android:gravity="start" would put it to the top left.

1

This will help you. Try this EditText....

<EditText
    android:id="@+id/edt_comment_note"
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:background="@drawable/white_box"
    android:gravity="top"
    android:hint="Note"
    android:imeOptions="actionDone"
    android:maxLines="3"
    android:padding="5dp"
    android:textSize="15sp" />
Mitul Goti
  • 2,657
  • 1
  • 22
  • 19