Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

android - Changing where cursor starts in an expanded EditText

I have TextField that is expanded from its normal single line width and height but the cursor to start typing in the EditText is always in the center of the expanded textfield when I change the height of the textfield and thats where it starts putting text too.

How can I get the cursor to the top left corner like normal while still keeping a bigger height box?

this is how my box is layout

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/camera_picture"
    android:layout_marginTop="58dp"
    android:ems="10"
    android:inputType="textMultiLine" >

    <requestFocus />
</EditText>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

set this in your xml

android:gravity="top"

you can also try this

android:gravity="top | left"

<EditText
    android:id="@+id/editText1"
    android:gravity="top"   <----------------
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/camera_picture"
    android:layout_marginTop="58dp"
    android:ems="10"
    android:inputType="textMultiLine" >

    <requestFocus />
</EditText>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...