本文整理匯總了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;
}