当前位置:网站首页>Kotlin Compose Text支持两种颜色
Kotlin Compose Text支持两种颜色
2022-07-06 21:38:00 【安果移不动】
首先可以用原生去渲染html
@Composable
fun TitleByYellow(
textAll: String,
textYellow: String? = null,
textSizeSp: Float = 15F,
@ColorRes textColorRes: Int = R.color.color_4A4A4A,
isBold: Boolean = false
) {
var text = textAll
if (!TextUtils.isEmpty(textYellow)) {
text = textAll.format("<font color='#F6CA2D'>$textYellow</font>")
}
val htmlDescription = Html.fromHtml(text)
AndroidView(factory = { context ->
val tv = TextView(context)
tv.apply {
textSize = textSizeSp
setTextColor(context.getColor(textColorRes))
if (isBold) {
setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
}
}
tv
},
update = {
it.text = htmlDescription
}
)
}
边栏推荐
- 预处理——插值
- QT 项目 表格新建列名称设置 需求练习(找数组消失的数字、最大值)
- Restore backup data on GCS with br
- 运算放大器应用汇总1
- Food Chem|深度学习根据成分声明准确预测食品类别和营养成分
- The true face of function pointer in single chip microcomputer and the operation of callback function
- GPT-3当一作自己研究自己,已投稿,在线蹲一个同行评议
- One of oscp tools: dirsearch usage Encyclopedia
- 2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
- 硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
猜你喜欢
随机推荐
How to manage the expiration of enterprise distribution certificates- How to manage Enterprise Distribution certificate expiration?
Food Chem|深度学习根据成分声明准确预测食品类别和营养成分
The true face of function pointer in single chip microcomputer and the operation of callback function
Operational amplifier application summary 1
Summer 2022 daily question 1 (1)
QT 使用QToolTip 鼠标放上去显示文字时会把按钮的图片也显示了、修改提示文字样式
Some thoughts on cross end development of kbone and applet
2022夏每日一题(一)
Construction of Hisilicon universal platform: color space conversion YUV2RGB
Class constant pool and runtime constant pool
Quick completion guide of manipulator (10): accessible workspace
termux设置电脑连接手机。(敲打命令贼快),手机termux端口8022
List interview common questions
学习使用js把两个对象合并成一个对象的方法Object.assign()
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
API data interface of A-share index component data
Class常量池与运行时常量池
QT opens a file and uses QFileDialog to obtain the file name, content, etc
Learn how to use js to merge two objects into one object assign()
Web service performance monitoring scheme