改变的地方光标开始在展开的EditText [英] Changing where cursor starts in an expanded EditText

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

问题描述

我有一个从它的正常单一线的宽度和高度,但光标到开始输入所述的EditText膨胀的TextField总是处于膨胀文本框的中心时更改文本字段并且那的高度,其中它开始把文本了。

我怎样才能得到光标移到左上角像正常的,同时仍保持较大的高度盒子?

这是我的盒子是布局

 <的EditText
    机器人:ID =@ + ID / editText1
    机器人:layout_width =match_parent
    机器人:layout_height =200dp
    机器人:layout_alignParentLeft =真
    机器人:layout_below =@ + ID / camera_picture
    机器人:layout_marginTop =58dp
    机器人:EMS =10
    机器人:inputType =textMultiLine>

    <不是requestFocus />
< /的EditText>
 

解决方案

其设置在你的XML

机器人:重力=顶

您也可以尝试这种

机器人:重力=顶|左

 <的EditText
    机器人:ID =@ + ID / editText1
    机器人:重力=顶< ----------------
    机器人:layout_width =match_parent
    机器人:layout_height =200dp
    机器人:layout_alignParentLeft =真
    机器人:layout_below =@ + ID / camera_picture
    机器人:layout_marginTop =58dp
    机器人:EMS =10
    机器人:inputType =textMultiLine>

    <不是requestFocus />
< /的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>

解决方案

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>

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

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