LineBackgroundSpan:PARAGRAPH范围必须从段落边界开始

问题描述

我试图将圆角应用于给定字符串中的代码标签

我的字符串如下:

This is a test <br/><br/> <code> Some code block here </code>

我想使用codeCustomLineBackgroundSpan(用于圆角)仅应用于TagHandler标记间的文本

class TagHandler() : Html.TagHandler {
    override fun handleTag(opening: Boolean,tag: String,output: Editable,xmlReader: XMLReader) {
        when (tag) {
            CODE_TAG -> handleCodeTag(opening,output)
        }
    }
   

    private fun handleCodeTag(opening: Boolean,output: Editable) = when {
        opening -> {
            start(output,CodeItem())
        }
        else -> {
             // just applies the span based on start and end index of the marker
             end<CodeItem>(
                output,// basic sample
                LineBackgroundSpan.Standard(Color.LTGRAY)
            )
        }
    }

但是上述设置似乎不适用于所有类型的字符串。

某些字符串,例如:This is a test <br/><br/> <code> Some code block here </code> some more text失败, ParaGRAPH span must start at paragraph boundary (5 follows )

我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)