Search code examples
androidandroid-edittexttextview

Text position in Android EditText


I have an issue when using EditText in my Android application. What I want is a large editable window where the user can start typing after an initial text in the top left corner (typing starts after the text). The issue is that the initial text is not printed in the top of the View.

When using a TextView it look like this, which is what I want:

TextView

But when changing to an EditText it look like this:

EditText

What property does set the text position? I've tried to change padding and paddingTop but none of them seem to make any difference. There is also a textAlignment which also does not do what I want.

Update: The properties:

    <EditText
    android:id="@+id/command_window_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_weight="0.33"
    android:background="@android:color/black"
    android:editable="true"
    android:fontFamily="monospace"
    android:padding="0dp"
    android:paddingStart="0dp"
    android:paddingTop="0dp"
    android:text="Example"
    android:textAlignment="viewStart"
    android:textColor="@android:color/holo_green_dark"
    android:textSize="14sp" />

Solution

  • Using android:gravity should work.