当前位置:网站首页>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
}
)
}
边栏推荐
- Unity3D在一建筑GL材料可以改变颜色和显示样本
- 机器人(自动化)课程的持续学习-2022-
- 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
- 使用Thread类和Runnable接口实现多线程的区别
- ggplot 分面的细节调整汇总
- List interview common questions
- 史上最全MongoDB之安全认证
- 机械臂速成小指南(十):可达工作空间
- Golang calculates constellations and signs based on birthdays
- 什么是 CGI,什么是 IIS,什么是VPS「建议收藏」
猜你喜欢
[MySQL] row sorting in MySQL
【OA】Excel 文档生成器: Openpyxl 模块
[ArcGIS tutorial] thematic map production - population density distribution map - population density analysis
[OA] excel document generator: openpyxl module
Class常量池与运行时常量池
【knife-4j 快速搭建swagger】
web服务性能监控方案
Class constant pool and runtime constant pool
机械臂速成小指南(十):可达工作空间
AVL树插入操作与验证操作的简单实现
随机推荐
高薪程序员&面试题精讲系列120之Redis集群原理你熟悉吗?如何保证Redis的高可用(上)?
Highly paid programmers & interview questions. Are you familiar with the redis cluster principle of series 120? How to ensure the high availability of redis (Part 1)?
Restore backup data on GCS with br
使用Thread类和Runnable接口实现多线程的区别
What is CGI, IIS, and VPS "suggested collection"
二进制、八进制、十六进制
机械臂速成小指南(十):可达工作空间
力扣------路径总和 III
The most complete learning rate adjustment strategy in history LR_ scheduler
Redis源码学习(30),字典学习,dict.h
Kotlin Compose Text支持两种颜色
termux设置电脑连接手机。(敲打命令贼快),手机termux端口8022
Analysis on the thinking of college mathematical modeling competition and curriculum education of the 2022a question of the China Youth Cup
Learn how to use js to merge two objects into one object assign()
Hangzhou Electric 3711 binary number
Formation continue en robotique (automatisation) - 2022 -
POJ training plan 2253_ Frogger (shortest /floyd)
一些常用软件相关
【刷题记录】2. 两数相加
[record of question brushing] 2 Add two numbers