Sheehan Alam
Sheehan Alam

Reputation: 60889

How to align EditText cursor properly?

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>

Upvotes: 6

Views: 3833

Answers (3)

A.Toledano
A.Toledano

Reputation: 1

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.

Upvotes: 0

inazaruk
inazaruk

Reputation: 74790

You should use gravity attribute:

<EditText android:gravity="left|bottom" ... />

Upvotes: 4

Related Questions