本文整理汇总了Java中android.text.Spanned.SPAN_COMPOSING属性的典型用法代码示例。如果您正苦于以下问题:Java Spanned.SPAN_COMPOSING属性的具体用法?Java Spanned.SPAN_COMPOSING怎么用?Java Spanned.SPAN_COMPOSING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.Spanned
的用法示例。
在下文中一共展示了Spanned.SPAN_COMPOSING属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAndMergeSpans
public static void setAndMergeSpans(Spannable text, Object what, int start, int end, int flags) {
Object[] spans = text.getSpans(Math.max(start - 1, 0), Math.min(end + 1, 0), what.getClass());
for (Object span : spans) {
if (!areSpansEqual(span, what))
continue;
int sFlags = text.getSpanFlags(span);
if ((sFlags & Spanned.SPAN_COMPOSING) != 0)
continue;
int sStart = text.getSpanStart(span);
int sEnd = text.getSpanEnd(span);
if (sEnd < start || sStart > end)
continue;
text.removeSpan(span);
if (sStart < start)
start = sStart;
if (sEnd > end)
end = sEnd;
}
text.setSpan(what, start, end, flags);
}
示例2: updateFormattingAtCursor
public void updateFormattingAtCursor() {
if (mEditText == null)
return;
Editable text = mEditText.getText();
int start = mEditText.getSelectionStart();
int end = mEditText.getSelectionEnd();
Object[] spans = text.getSpans(start, end, Object.class);
mBoldButton.setSelected(false);
mItalicButton.setSelected(false);
mUnderlineButton.setSelected(false);
int fgColor = -1;
int bgColor = -1;
for (Object span : spans) {
if (!SpannableStringHelper.checkSpanInclude(text, span, start, end) ||
(text.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0)
continue;
if (span instanceof StyleSpan) {
int style = ((StyleSpan) span).getStyle();
if (style == Typeface.BOLD)
mBoldButton.setSelected(true);
else if (style == Typeface.ITALIC)
mItalicButton.setSelected(true);
} else if (span instanceof UnderlineSpan) {
mUnderlineButton.setSelected(true);
} else if (span instanceof ForegroundColorSpan) {
fgColor = ((ForegroundColorSpan) span).getForegroundColor();
} else if (span instanceof BackgroundColorSpan) {
bgColor = ((BackgroundColorSpan) span).getBackgroundColor();
}
}
ImageViewCompat.setImageTintList(mTextColorValue, fgColor != -1
? ColorStateList.valueOf(fgColor) : mTextColorValueDefault);
ImageViewCompat.setImageTintList(mFillColorValue, bgColor != -1
? ColorStateList.valueOf(bgColor) : mFillColorValueDefault);
}
示例3: hasCompositionString
private static boolean hasCompositionString(Editable content) {
Object[] spans = content.getSpans(0, content.length(), Object.class);
if (spans != null) {
for (Object span : spans) {
if ((content.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) {
// Found composition string.
return true;
}
}
}
return false;
}