当前位置:网站首页>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
}
)
}
边栏推荐
- Kbone与小程序跨端开发的一些思考
- Web service performance monitoring scheme
- Termux set up the computer to connect to the mobile phone. (knock the command quickly), mobile phone termux port 8022
- What is the experience of maintaining Wanxing open source vector database
- [coded font series] opendyslexic font
- 2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
- pyqt5 失焦 监听无操作 定时器
- 手机号国际区号JSON格式另附PHP获取
- leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
- The first introduction of the most complete mongodb in history
猜你喜欢
Create commonly used shortcut icons at the top of the ad interface (menu bar)
ABAP 動態內錶分組循環
The most complete security certification of mongodb in history
tflite模型转换和量化
Force buckle ----- path sum III
[written to the person who first published the paper] common problems in writing comprehensive scientific and Technological Papers
超越Postman,新一代国产调试工具Apifox,用起来够优雅
Implementation of map and set
运算放大器应用汇总1
5年自动化测试,终于进字节跳动了,年薪30w其实也并非触不可及
随机推荐
tflite模型转换和量化
Imitate Tengu eating the moon with Avatar
Opencv third party Library
使用 BR 恢复 GCS 上的备份数据
機器人(自動化)課程的持續學習-2022-
Redis源码学习(31),字典学习,dict.c(一)
使用 BR 备份 TiDB 集群到 GCS
Tflite model transformation and quantification
How to detect whether the MySQL code runs deadlock +binlog view
Antd comment recursive loop comment
Kbone与小程序跨端开发的一些思考
What is the experience of maintaining Wanxing open source vector database
Hangzhou Electric 3711 binary number
The most complete learning rate adjustment strategy in history LR_ scheduler
SSM+jsp实现仓库管理系统,界面那叫一个优雅
Mongo shell, the most complete mongodb in history
2022 middle school Youth Cup mathematical modeling question B fertility policy research ideas under the background of open three children
【系统管理】清理任务栏的已删除程序的图标缓存
Redis源码学习(30),字典学习,dict.h
Implementation of binary search tree