android edittext 禁止自动换行,Android EditText 为什么不能自动换行

写了一个布局文件 即使设置了singleLine = false; 也无效,当然代码中也没对edittext做过任何处理。

android:id="@+id/add_info_edit"

android:layout_width="match_parent"

android:layout_height="100dp"

android:layout_gravity="center"

android:background="@drawable/btn_13"

android:gravity="left"

android:hint="请输入验证信息 : 如我是"

android:inputType="text"

android:textColor="@color/gray_hint_color"

android:textSize="@dimen/daohang_two_txt_size"

android:singleLine="false"/>

最终解决方案是:inputtype 的更改

android:id="@+id/add_info_edit"

android:layout_width="match_parent"

android:layout_height="100dp"

android:layout_gravity="center"

android:background="@drawable/btn_13"

android:gravity="left"

android:hint="请输入验证信息 : 如我是"

android:inputType="textMultiLine"

android:textColor="@color/gray_hint_color"

android:textSize="@dimen/daohang_two_txt_size" />

inputtype= “textMultiLine"

”Can be combined with text and its variations to allow multiple lines of text in the field. If this flag is not set, the text field will be constrained to a single line.

InputType总结:

android:inputType="none"--输入普通字符

android:inputType="text"--输入普通字符

android:inputType="textCapCharacters"--输入普通字符

android:inputType="textCapWords"--单词首字母大小

android:inputType="textCapSentences"--仅第一个字母大小

android:inputType="textAutoCorrect"--前两个自动完成

android:inputType="textAutoComplete"--前两个自动完成

android:inputType="textMultiLine"--多行输入

android:inputType="textImeMultiLine"--输入法多行(不一定支持)

android:inputType="textNoSuggestions"--不提示

android:inputType="textUri"--URI格式

android:inputType="textEmailAddress"--电子邮件地址格式

android:inputType="textEmailSubject"--邮件主题格式

android:inputType="textShortMessage"--短消息格式

android:inputType="textLongMessage"--长消息格式

android:inputType="textPersonName"--人名格式

android:inputType="textPostalAddress"--邮政格式

android:inputType="textPassword"--密码格式

android:inputType="textVisiblePassword"--密码可见格式

android:inputType="textWebEditText"--作为网页表单的文本格式

android:inputType="textFilter"--文本筛选格式

android:inputType="textPhonetic"--拼音输入格式

android:inputType="number"--数字格式

android:inputType="numberSigned"--有符号数字格式

android:inputType="numberDecimal"--可以带小数点的浮点格式

android:inputType="phone"--拨号键盘

android:inputType="datetime"

android:inputType="date"--日期键盘

android:inputType="time"--时间键盘

当然还可以为EditText设置多个Inputtype

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:inputType="numberSigned|numberDecimal"

android:hint="numberSigned-numberDecinal" />

自己的小小总结:

当inputtype = numberSigned时 键盘上的“-”号可以使用,当inputtype = numberDecimal时 键盘上的“.”可以使用。盆友们 ,有知道当inputtype = textCapWords时 是什么效果?

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值