Changing where cursor starts in an expanded EditText(更改光标在展开的 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 中的开始位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更改光标在展开的 EditText 中的开始位置
基础教程推荐
- Android:STATE_SELECTED不工作 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
