简体   繁体   中英

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>

你应该使用gravity属性:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM