最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Android中字符设置为全部大写

Android crifan 4155浏览 0评论

【背景】

Android中,想要把一个LinearLayout的标题变成都是大写。

【折腾过程】

1.搜:

android text Capitalize

找到:

android – Is there a way to style a TextView to uppercase all of its letters? – Stack Overflow

->

Text-transform:uppercase equivalent in Android? – Stack Overflow

最后用:

        //varaibleGroupNameView.setText(groupName);
        varaibleGroupNameView.setText(groupName.toUpperCase());

是可以实现目的的。

2.再去参考:

TextView | Android Developers

试试:

        //varaibleGroupNameView.setText(groupName);
        //varaibleGroupNameView.setText(groupName.toUpperCase());
        varaibleGroupNameView.setText(groupName);
        varaibleGroupNameView.setAllCaps(true);

效果会更好:

只需要对于TextView等控件,最后调用一下setAllCaps(true)即可。

效果如下:

android the group title text is all capitalized

 

【总结】

想要把字符都大写,则只需,其他什么都不变的情况下,调用:

someTextView.setAllCaps(true);

即可。

转载请注明:在路上 » 【已解决】Android中字符设置为全部大写

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.149 seconds, using 22.12MB memory