How to align EditText cursor properly?
Asked Answered
U

3

6

I have an edit text with a 200sp size. The cursor appears in the middle. How can I make sure the cursor appears in the left corner? It looks odd being in the center.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/composeEditText" android:minHeight="200sp" android:focusable="true" android:hint="Share an idea with the community"></EditText>
    <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/toolbarLinearLayout">
        <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/sendButton" android:text="Send"></Button>
        <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/shortenButton" android:text="Shorten"></Button>
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/charCountTextView" android:text="140"></TextView>
    </LinearLayout>

</LinearLayout>
Unbuild answered 23/5, 2011 at 16:7 Comment(0)
R
14

Use android:gravity="top|left"

http://developer.android.com/reference/android/widget/TextView.html#attr_android:gravity

Royer answered 23/5, 2011 at 16:15 Comment(0)
K
4

You should use gravity attribute:

<EditText android:gravity="left|bottom" ... />
Kumkumagai answered 23/5, 2011 at 16:16 Comment(0)
D
0

I know it's an old post,possibly it wasn't relevant then... now we use android:gravity="top|start" or android:gravity="bottom|start"

so it will match it to the locale.

Duplication answered 25/7, 2018 at 7:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.