Android奇怪问题—–Button的setText()方法都是大写
详细描述一下问题,在给Button设置文本内容的时候,字母莫名奇妙的统统变成了大写,如代码为setText(“sheep”),显示的确实SHEEP
截取相应的xml入下
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="A"
android:id="@+id/A"
android:background="@color/accent_material_light"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/C"
android:layout_toEndOf="@+id/C" />
操作代码:
A.setText(words[0]);
B.setText(words[1]);
C.setText(words[2]);
D.setText(words[3]);
笔者保证这些字符都是小写。
解决方法
- 在xml中加入android:textAllCaps=”false”即可解决,原因还未找到,如果有朋友碰到过,希望指导一下,不胜感激。