更改光标在展开的 EditText 中的开始位置 [英] Changing where cursor starts in an expanded EditText

查看:22
本文介绍了更改光标在展开的 EditText 中的开始位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 TextField 从其正常的单行宽度和高度扩展,但是当我更改文本字段的高度时,开始在 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?

这就是我的盒子的布局

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

推荐答案

在你的xml中设置这个

set this in your xml

android:gravity="top"

你也可以试试这个

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>

这篇关于更改光标在展开的 EditText 中的开始位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆