Android Button#setText 不区分大小写问题

2018-05-22  本文已影响0人  AlanFu
问题描述:

在给Button设置文本内容的时候,字母莫名奇妙的统统变成了大写,如代码为setText(“sheep”),显示为SHEEP。

解决方法:
在xml中button节点加入android:textAllCaps=”false” 
或者 
button.setAllCaps(false);
再或者
button.setTransformationMethod(null);
产生原因:

Sets the properties of this field to transform input to ALL CAPS
display. This may use a "small caps" formatting if available.
This setting will be ignored if this field is editable or selectable.
This call replaces the current transformation method. Disabling this
will not necessarily restore the previous behavior from before this
was enabled.

参考文章:

https://blog.csdn.net/baidu_30889437/article/details/51956563
https://www.aliyun.com/jiaocheng/42095.html

上一篇下一篇

猜你喜欢

热点阅读