Как правильно выровнять курсор EditText? - PullRequest
6 голосов
/ 23 мая 2011

У меня есть текст для редактирования с размером 200sp. Курсор появляется в середине. Как я могу убедиться, что курсор появляется в левом углу? Это выглядит странно, находясь в центре.

<?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>

Ответы [ 3 ]

14 голосов
/ 23 мая 2011
4 голосов
/ 23 мая 2011

Вы должны использовать атрибут gravity:

<EditText android:gravity="left|bottom" ... />
0 голосов
/ 25 июля 2018

Я знаю, что это старый пост, возможно, тогда он не был актуален ... теперь мы используем android: gravity = "top | start" или android: gravity = "bottom | start"

, так чтобудет соответствовать этому языку.

...