当前位置:网站首页>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
}
)
}边栏推荐
- 【开发软件】 tilipa开发者软件
- OSCP工具之一: dirsearch用法大全
- CUDA Programming
- 本机mysql
- Do you choose pandas or SQL for the top 1 of data analysis in your mind?
- How to manage the expiration of enterprise distribution certificates- How to manage Enterprise Distribution certificate expiration?
- Use facet to record operation log
- MySQL data loss, analyze binlog log file
- 2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析
- 学习使用js把两个对象合并成一个对象的方法Object.assign()
猜你喜欢
接口数据安全保证的10种方式

【系统管理】清理任务栏的已删除程序的图标缓存

一些常用软件相关

Quick completion guide of manipulator (10): accessible workspace

你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
![[security attack and Defense] how much do you know about serialization and deserialization?](/img/1c/e5ae74e65bacf688d7f61cc1b71d3e.png)
[security attack and Defense] how much do you know about serialization and deserialization?

Que savez - vous de la sérialisation et de l'anti - séquence?

Food Chem|深度学习根据成分声明准确预测食品类别和营养成分

Codeworks 5 questions per day (1700 average) - day 7

Storage of data
随机推荐
CUDA Programming
Mysql-数据丢失,分析binlog日志文件
超越Postman,新一代国产调试工具Apifox,用起来够优雅
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
三重半圆环进度条,直接拿去就能用
机器人(自动化)课程的持续学习-2022-
QT opens a file and uses QFileDialog to obtain the file name, content, etc
使用Thread类和Runnable接口实现多线程的区别
Termux set up the computer to connect to the mobile phone. (knock the command quickly), mobile phone termux port 8022
10 ways of interface data security assurance
Food Chem|深度学习根据成分声明准确预测食品类别和营养成分
Antd Comment 递归循环评论
链表面试常见题
Simple implementation of AVL tree insertion and verification operations
Using thread class and runnable interface to realize the difference between multithreading
2022电工杯A题高比例风电电力系统储能运行及配置分析思路
Docker部署Mysql8的实现步骤
What is the experience of maintaining Wanxing open source vector database
Collection of idea gradle Lombok errors
使用 TiDB Lightning 恢复 GCS 上的备份数据