本文整理汇总了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>");
}
}
}