android 多行编辑框,Android:多行EditText(文本区域)的垂直对齐

Android:多行EditText(文本区域)的垂直对齐

我希望文本区域的高度有5行。 我使用以下代码。

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:gravity="center"

android:singleLine="false"

android:lines="5"

android:layout_marginLeft="10dip"

android:layout_marginRight="10dip" />

文本区域看起来很好,但问题是光标在文本字段的中间闪烁。 我希望它在文本字段的第一个字符的第一行闪烁。

7个解决方案

351 votes

使用android:gravity="top"

CommonsWare answered 2019-02-24T04:43:39Z

92 votes

这类似于CommonsWare的答案,但有一个小调整:android:gravity="top|left"。完整的代码示例:

android:id="@+id/EditText02"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:lines="5"

android:gravity="top|left"

android:inputType="textMultiLine"

android:scrollHorizontally="false"

/>

Nandagopal T answered 2019-02-24T04:44:04Z

17 votes

你可以使用这个Edittext ....这将对你有所帮助。

android:id="@+id/EditText02"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:lines="5"

android:gravity="top|left"

android:inputType="textMultiLine" />

Denny Sharma answered 2019-02-24T04:44:29Z

9 votes

用这个:

android:gravity="top"

要么

android:gravity="top|left"

Samir Mangroliya answered 2019-02-24T04:44:53Z

6 votes

android:layout_height="wrap_content" android:lines="5" android:layout_centerInParent="true"

android:gravity="top|left" android:inputType="textMultiLine"

android:scrollHorizontally="false" android:minWidth="10.0dip"

android:maxWidth="180dip" />

它会工作

Asad Rao answered 2019-02-24T04:45:25Z

2 votes

我认为你可以使用layout:weight = 5而不是android:lines = 5,因为当你将你的应用程序移植到更小的设备时 - 它做得很好..好吧,这两个属性将完成你的工作..

Sanjay Herle answered 2019-02-24T04:45:57Z

0 votes

现在每天使用重力start是最好的选择:

android:gravity="start"

对于EditText(textarea):

android:id="@+id/EditText02"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:lines="5"

android:gravity="start"

android:inputType="textMultiLine"

/>

Hasib Akter answered 2019-02-24T04:46:38Z

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值