我需要将文本=“font roboto regular”改为Font Roboto Regular在xml本身,该怎么办?
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textSize="18sp" android:textColor="@android:color/black" android:fontFamily="roboto-regular" android:text="font roboto regular" android:inputType="textCapWords" android:capitalize="words"/>
解决方法
你可以使用这段代码.
String str = "font roboto regular"; String[] strArray = str.split(" "); StringBuilder builder = new StringBuilder(); for (String s : strArray) { String cap = s.substring(0,1).toUpperCase() + s.substring(1); builder.append(cap + " "); } TextView textView = (TextView) findViewById(R.id.textView); textView.setText(builder.toString());
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。