当前位置:网站首页>Kotlin compose text supports two colors
Kotlin compose text supports two colors
2022-07-07 04:15:00 【Ango can't move】
First, you can use native to render 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
}
)
}
边栏推荐
- [leetcode]Spiral Matrix II
- Formation continue en robotique (automatisation) - 2022 -
- EasyUI export excel cannot download the method that the box pops up
- Redis configuration and optimization of NoSQL
- [development software] tilipa Developer Software
- Unity3d can change colors and display samples in a building GL material
- pyqt5 失焦 监听无操作 定时器
- Restore backup data on GCS with tidb lightning
- 一些常用软件相关
- Implementation of map and set
猜你喜欢
CUDA Programming
AVL树插入操作与验证操作的简单实现
史上最全MongoDB之安全认证
【ArcGIS教程】专题图制作-人口密度分布图——人口密度分析
史上最全学习率调整策略lr_scheduler
How to detect whether the MySQL code runs deadlock +binlog view
Tflite model transformation and quantification
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
运算放大器应用汇总1
Quick completion guide of manipulator (10): accessible workspace
随机推荐
Tflite model transformation and quantification
红米k40s root玩机笔记
Ggplot facet detail adjustment summary
Kotlin Compose Text支持两种颜色
ERROR: Could not build wheels for pycocotools which use PEP 517 and cannot be installed directly
Learn how to use js to merge two objects into one object assign()
Implementation of binary search tree
数据的存储
Implementation steps of docker deploying mysql8
cuda编程
手机号国际区号JSON格式另附PHP获取
史上最全MongoDB之安全认证
The first introduction of the most complete mongodb in history
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
杭州电 3711 Binary Number
[hcie TAC] question 3
How to detect whether the MySQL code runs deadlock +binlog view
使用Thread类和Runnable接口实现多线程的区别
使用 Dumpling 备份 TiDB 集群数据到 GCS
运算放大器应用汇总1