Reputation: 466
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:
But when changing to an EditText it look like this:
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" />
Upvotes: 0
Views: 3337
Reputation: 1
Use gravity="number"
In example :
<EditText
android:id="@+id/simpleEditText"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:text="Please Ebter"
android:gravity="2"
/>
Upvotes: 0
Reputation: 477
<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:paddingTop="0dp"
android:text="Example"
android:lines="10"
android:textAlignment="center"
android:layout_below="@+id/card"
android:textColor="@android:color/holo_green_dark"
android:textSize="14sp" />
Upvotes: 1
Reputation: 883
Use gravity="top"
Example:
<EditText
android:id="@+id/tv_weather_data"
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:textSize="20sp" />
Upvotes: 0