解释跨度标志像SPAN_EXCLUSIVE_EXCLUSIVE的意义 [英] Explain the meaning of Span flags like SPAN_EXCLUSIVE_EXCLUSIVE

查看:549
本文介绍了解释跨度标志像SPAN_EXCLUSIVE_EXCLUSIVE的意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以清楚地例举了每个跨度标志像<$ C $解释C> SPAN_EXCLUSIVE_EXCLUSIVE 和 SPAN_MARK_MARK 的意思是,何时使用什么标志?

我不明白的官方文档时,它说:

  

键入 SPAN_EXCLUSIVE_EXCLUSIVE 的跨度不扩展到包括文本   插在任的起点或终点。

难道扩大到是指插入跨度后作出修改?

这是否意味着这些标志不影响Spannables万古不易的文字?

解决方案
  

难道扩大到是指插入跨度后作出修改?

是的。例如,假设我们有以下几点:

快速狐狸跳了下去。

如果我们使用 SPAN_EXCLUSIVE_EXCLUSIVE 上的黑体字跨度,我们插入跨度的中间文本,它仍然是黑体字:

敏捷的棕色狐狸跳了下去。

然而,如果我们插入文本的开头或粗体跨度结束时,插入的文本不是粗体字:

真正的快速狐狸跳了下去。

然而,如果我们使用 SPAN_INCLUSIVE_EXCLUSIVE ,然后插入文本开头将作为跨度的一部分,我们将有:

真快狐狸跳了下去。

  

这是否意味着这些标志不影响Spannables万古不易的文字?

我会说,他们只有有限的用途不变的文本。大多数情况下,这些将用于与 SpannableStringBuilder 或使用一个在幕后(例如,的EditText )的东西。

Can someone clearly explain with examples what each of the span flags like SPAN_EXCLUSIVE_EXCLUSIVE and SPAN_MARK_MARK mean and when to use what flags?

I do not understand the official documentation when it says:

Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand to include text inserted at either their starting or ending point.

Does "expand to include" refer to edits made after inserting the spans?

Does it mean that these flags do NOT affect Spannables with immutable text?

解决方案

Does "expand to include" refer to edits made after inserting the spans?

Yes. For example, let's suppose we have the following:

The quick fox jumped.

If we used SPAN_EXCLUSIVE_EXCLUSIVE on the boldface span, and we insert text in the middle of the span, it is still boldface:

The quick brown fox jumped.

However, if we insert text at the beginning or the end of the boldface span, the inserted text is not boldface:

The really quick fox jumped.

If, however, we had used SPAN_INCLUSIVE_EXCLUSIVE, then inserting text at the beginning would be included as part of the span, and we would have:

The really quick fox jumped.

Does it mean that these flags do NOT affect Spannables with immutable text?

I would say that they have limited use for immutable text. Mostly, these will be used with SpannableStringBuilder or things that use one under the covers (e.g., EditText).

这篇关于解释跨度标志像SPAN_EXCLUSIVE_EXCLUSIVE的意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆