我需要将文本=“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());