How to disable auto-capitalization of an EditText

天大地大妈咪最大 提交于 2019-11-28 00:14:28

问题


This will have a really simple answer, but I can't seem to find what it is. I want to disable the auto-capitalization of an EditText so that, by default, the first letter entered with not be automatically capitalized. I still want to allow capitalization, but only if the user manually does so.

I've tried android:capitalize="none" on my EditText, and I've tried android:inputType="text" but both still auto-capitalize the first letter. I don't want to use a TextWatcher because on the soft keyboard it will still show the shift key as pressed for the first letter, and I'm nit-picky and don't want that to show.


回答1:


You could try using android:inputType="none" instead.

UPDATE:

You could also try using android:inputType="text|textEmailAddress"




回答2:


Have you tried android:inputType="textFilter"? That will disable all text filters, so there's no auto-correcting.




回答3:


For posterity, I think what you're (or more accurately, whoever finds this in the future) looking for is this table of all the options that can be used for the inputType:
https://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType

In this specific case, I would recommend "text".
Just plain old text. Corresponds to TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_NORMAL.



来源:https://stackoverflow.com/questions/6976950/how-to-disable-auto-capitalization-of-an-edittext

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