さて、私はリッチ テキスト エディターを構築しようとしています。編集可能なテキスト (太字、斜体、URL など) をフォーマットするためのボタンがいくつかあります。すべてのテキスト修正オプションを有効にしてGoogle キーボード
を使用しています ( [設定] > [言語と入力] > [ Google キーボード] > [テキスト修正] )。
私は次のことを行います:
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 スパンをサブクラス化します。
Google キーボードがスパンを独自に変更しているようです (おそらくShow suggestions
設定のため)。
どうすればこれを回避できますか?
たぶん、スパンフラグについて何か不足していますか?