好吧,我尝试构建一个富文本编辑器。我有一些按钮来格式化我的可编辑文本(粗体、斜体、URL 等)。
我使用启用了所有文本更正选项的谷歌键盘(设置>语言和输入>谷歌键盘>文本更正)。
我执行以下操作:
我选择它并应用带有SPAN_EXCLUSIVE_EXCLUSIVE
(33) 作为标志的粗体跨度。
好的,这就是问题所在。我的粗体跨度标志已经改变......为什么!?
这是一些日志:
D/ContentUtils: beforeTextChanged: start end span flags
D/ContentUtils: beforeTextChanged: 0 7 ChangeWatcher 8388626
D/ContentUtils: beforeTextChanged: 0 7 ChangeWatcher 6553618
D/ContentUtils: beforeTextChanged: 0 7 TextKeyListener 18
D/ContentUtils: beforeTextChanged: 0 7 SpanController 18
D/ContentUtils: beforeTextChanged: 7 7 START 546
D/ContentUtils: beforeTextChanged: 7 7 END 34
D/ContentUtils: beforeTextChanged: 0 7 SpellCheckSpan 33
D/ContentUtils: beforeTextChanged: 0 7 CustomBoldSpan 33
D/ContentUtils: onTextChaghed
D/ContentUtils: onTextChaghed: 0 8 ChangeWatcher 8392722
D/ContentUtils: onTextChaghed: 0 8 ChangeWatcher 6557714
D/ContentUtils: onTextChaghed: 0 8 TextKeyListener 4114
D/ContentUtils: onTextChaghed: 0 8 SpanController 4114
D/ContentUtils: onTextChaghed: 8 8 START 546
D/ContentUtils: onTextChaghed: 8 8 END 34
D/ContentUtils: onTextChaghed: 0 8 CustomBoldSpan 4129
D/ContentUtils: onTextChaghed: 0 8 UnderlineSpan 289
D/ContentUtils: onTextChaghed: 0 8 ComposingText 289
D/ContentUtils: afterTextChanged
D/ContentUtils: afterTextChanged: 0 8 ChangeWatcher 8392722
D/ContentUtils: afterTextChanged: 0 8 ChangeWatcher 6557714
D/ContentUtils: afterTextChanged: 0 8 TextKeyListener 4114
D/ContentUtils: afterTextChanged: 0 8 SpanController 4114
D/ContentUtils: afterTextChanged: 8 8 START 546
D/ContentUtils: afterTextChanged: 8 8 END 34
D/ContentUtils: afterTextChanged: 0 8 CustomBoldSpan 4129
D/ContentUtils: afterTextChanged: 0 8 UnderlineSpan 289
D/ContentUtils: afterTextChanged: 0 8 ComposingText 289
D/ContentUtils: afterTextChanged: 0 8 SpellCheckSpan 33
当我使用另一个键盘时,一切都很好。
当我禁用文本校正设置时,一切正常。我所有的跨度都是自定义跨度,并且是现有 Android 跨度的子类。
谷歌键盘似乎自己修改了我的跨度(可能是因为Show suggestions
设置)。
我怎样才能避免这种情况?
也许我错过了一些关于跨度标志的东西?