Android virtual keyboard turn on caps lock

痴心易碎 提交于 2021-01-27 03:51:01

问题


I have an edit text field. When the user clicks on it by default it shows small letters on the virtual keyboard.

I want by default to display first letter caps and rest of them small on the keyboard.

How can this be done?


回答1:


Try adding android:capitalize="sentences" to the definition of the EditText in your Layout file. This should capitalize the first character of the sentence. If you want to begin each word with a capital letter use words.

More about this can be found in the API.




回答2:


android:capitalize is deprecated. So please use: android:inputType

android:inputType="textCapSentences"



回答3:


In order to captialize every character of EditText use these property.

android:capitalize="characters"



回答4:


I used below attribute with textCapCharacters value in my EditText to turn on caps lock on the virtual keypad and it worked.

android:inputType="textCapCharacters"



回答5:


To capitalize all characters of Keyboard use this in your edittext in xml:

android:inputType="textCapCharacters"

To capitalize of the first character of every sentence use this :

android:inputType="textCapSentences"


来源:https://stackoverflow.com/questions/2847221/android-virtual-keyboard-turn-on-caps-lock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!