Search code examples
javaandroidandroid-edittext

How do I start typing my description box in EditText from the top line in Android Studio?


I have added the picture to show that my current description box does not start from the first line when I start to type, how do I make it to start from the top left corner?

Description box not starting from top left corner

<EditText
    android:id="@+id/et_message"
    android:layout_width="350dp"
    android:layout_height="150dp"
    android:layout_marginLeft="25dp"
    android:layout_marginTop="390dp"
    android:background="@color/white"/>

I have added my xml code for the description box above.


Solution

  • You should use android:gravity="start|top" in your EditText. for more details read here

    <EditText
        android:id="@+id/et_message"
        android:layout_width="350dp"
        android:layout_height="150dp"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="390dp"
        android:gravity="start|top"
        android:background="@color/white"
        android:text="@string/app_name"
        tools:ignore="MissingConstraints" />