gpt4 book ai didi

android - 如何在Textview xml中将每个单词的第一个字母更改为大写

转载 作者:IT王子 更新时间:2023-10-28 23:26:57 26 4
gpt4 key购买 nike

我需要把xml本身的text="font roboto regular"改成Font Roboto Regular,怎么办?

<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"/>

最佳答案

如果有人在寻找 kotlin 这样做的方式,那么代码就变得非常简单和美观了。

yourTextView.text = yourText.split(' ').joinToString(" ") { it.capitalize() }

关于android - 如何在Textview xml中将每个单词的第一个字母更改为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35177726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com