当前位置:网站首页>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
}
)
}
边栏推荐
- 使用 BR 恢复 GCS 上的备份数据
- Termux set up the computer to connect to the mobile phone. (knock the command quickly), mobile phone termux port 8022
- Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
- 2022电工杯A题高比例风电电力系统储能运行及配置分析思路
- One of oscp tools: dirsearch usage Encyclopedia
- Class constant pool and runtime constant pool
- 手机号国际区号JSON格式另附PHP获取
- Restore backup data on GCS with tidb lightning
- Ggplot facet detail adjustment summary
- Arduino droplet detection
猜你喜欢
史上最全MongoDB之安全认证
Gpt-3 is a peer review online when it has been submitted for its own research
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
ABAP dynamic inner table grouping cycle
Top 50 hit industry in the first half of 2022
SQL injection -day15
On file uploading of network security
【mysql】mysql中行排序
Kotlin Android environment construction
tflite模型转换和量化
随机推荐
【刷题记录】2. 两数相加
The true face of function pointer in single chip microcomputer and the operation of callback function
ABAP dynamic inner table grouping cycle
如何检测mysql代码运行是否出现死锁+binlog查看
数据的存储
Adaptive non European advertising retrieval system amcad
CUDA Programming
机械臂速成小指南(十):可达工作空间
ABAP 动态内表分组循环
golang 根据生日计算星座和属相
Unity3D在一建筑GL材料可以改变颜色和显示样本
Implementation of binary search tree
Confirm the future development route! Digital economy, digital transformation, data This meeting is very important
web服务性能监控方案
二进制、八进制、十六进制
Construction of Hisilicon universal platform: color space conversion YUV2RGB
[security attack and Defense] how much do you know about serialization and deserialization?
Preprocessing - interpolation
On file uploading of network security
QT item table new column name setting requirement exercise (find the number and maximum value of the array disappear)