本文整理匯總了Java中android.text.Spanned.nextSpanTransition方法的典型用法代碼示例。如果您正苦於以下問題:Java Spanned.nextSpanTransition方法的具體用法?Java Spanned.nextSpanTransition怎麽用?Java Spanned.nextSpanTransition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.text.Spanned
的用法示例。
在下文中一共展示了Spanned.nextSpanTransition方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: encodeTextAlignmentByDiv
import android.text.Spanned; //導入方法依賴的package包/類
private static void encodeTextAlignmentByDiv(Context context, StringBuilder out, Spanned text, int option) {
int len = text.length();
int next;
for (int i = 0; i < len; i = next) {
next = text.nextSpanTransition(i, len, ParagraphStyle.class);
ParagraphStyle[] styles = text.getSpans(i, next, ParagraphStyle.class);
String elements = " ";
boolean needDiv = false;
for (ParagraphStyle style : styles) {
if (style instanceof AlignmentSpan) {
Layout.Alignment align =
((AlignmentSpan) style).getAlignment();
needDiv = true;
if (align == Layout.Alignment.ALIGN_CENTER) {
elements = "align=\"center\" " + elements;
} else if (align == Layout.Alignment.ALIGN_OPPOSITE) {
elements = "align=\"right\" " + elements;
} else {
elements = "align=\"left\" " + elements;
}
}
}
if (needDiv) {
out.append("<div ").append(elements).append(">");
}
withinDiv(context, out, text, i, next, option);
if (needDiv) {
out.append("</div>");
}
}
}