android - Android TextView, lineSpacingExtra + backgroundColor 问题
问题描述
我正在使用带有 SpannableString 的 TextView 来更改某些单词的背景颜色,如下图所示,但 attr 'lineSpacingExtra' 存在问题。如您所见,使用“lineSpacingExtra”时添加了一些底部填充。我想知道如何使这个填充适合文本的高度。
这是我的代码片段。
在.kt
spannableString.setSpan(BackgroundColorSpan({color}), 0, text.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
在 .xml 中
<TextView
android:id="@+id/tv_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:lineSpacingExtra="6dp"/>
我该如何解决这个问题?谢谢。
解决方案
推荐阅读
- c - 多子部分加法的流程API
- r - 如何在ggplot方面按值排序数据
- node.js - 不一致 - “用于调用 Google Play Developer API 的项目 ID 尚未在 Google Play Developer Console 中链接。”
- symfony - empty_data 不适用于复合形式,或者实体没有被实例化(ArgumentCountError:函数的参数太少)
- reactjs - react: setstate 的可重用事件处理程序
- javascript - Vue DOM 更新不会在第一次点击中发生,在后续点击中有效
- python - 如何修复使用 pymssql 插入 sql DB 的错误
- angular - 我没有从 'fromEvent(window, 'scroll')'l 得到任何事件
- c# - SaveFileDialog 找不到桌面文件夹路径
- sql - 如何检查表中正在使用的空间,包括幽灵记录