如何强制EditText以大写字母开头的文本? [英] How to force EditText to start text with capital letter?

查看:130
本文介绍了如何强制EditText以大写字母开头的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个EditText,我需要其中的文本(当用户键入时)以大写字母开头.

解决方案

如果同时添加android:capitalize="sentences"android:inputType="text",请小心,因为后者似乎优先于第一个,并且输入内容不会大写./p>

有一个特定的inputType可自动将首字母大写:

android:inputType="textCapSentences"

请参见 http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType

I have an EditText and I need the text in it (when user types in) to be started with capital letter.

解决方案

Be careful if you add both android:capitalize="sentences" and android:inputType="text", as the latter seems to have priority over the first and the input will not be capitalized.

There's a specific inputType for automatically capitalizing the first letter:

android:inputType="textCapSentences"

See http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType

这篇关于如何强制EditText以大写字母开头的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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