本文整理汇总了Java中android.text.style.LineHeightSpan类的典型用法代码示例。如果您正苦于以下问题:Java LineHeightSpan类的具体用法?Java LineHeightSpan怎么用?Java LineHeightSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineHeightSpan类属于android.text.style包,在下文中一共展示了LineHeightSpan类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearSpans
import android.text.style.LineHeightSpan; //导入依赖的package包/类
protected void clearSpans(Editable editable) {
clearCharacterSpanType(editable, TextAppearanceSpan.class);
clearCharacterSpanType(editable, ForegroundColorSpan.class);
clearCharacterSpanType(editable, BackgroundColorSpan.class);
clearCharacterSpanType(editable, StrikethroughSpan.class);
clearCharacterSpanType(editable, RelativeSizeSpan.class);
clearCharacterSpanType(editable, StyleSpan.class);
clearCharacterSpanType(editable, ColorUnderlineSpan.class);
clearParagraphSpanType(editable, LineBackgroundSpan.class);
clearParagraphSpanType(editable, LineHeightSpan.class);
}
示例2: getSpans
import android.text.style.LineHeightSpan; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T[] getSpans(int start, int end, Class<T> type) {
// Fast path for common time-critical spans that aren't there
if (type == MetricAffectingSpan.class && !mHasMetricAffectingSpan) {
return (T[]) EMPTY_METRIC_AFFECTING_SPAN_ARRAY;
}
if (type == ReplacementSpan.class && !mHasReplacementSpan) {
return (T[]) EMPTY_REPLACEMENT_SPAN_ARRAY;
}
if (!mHasParagraphStyle) {
if (type == LeadingMarginSpan.class) {
return (T[]) EMPTY_LEADING_MARGIN_SPAN_ARRAY;
}
if (type == LineHeightSpan.class) {
return (T[]) EMPTY_LINE_HEIGHT_SPAN_ARRAY;
}
if (type == TabStopSpan.class) {
return (T[]) EMPTY_TAB_STOP_SPAN_ARRAY;
}
}
T[] spansFromSuperclass = mSpannableString.getSpans(start, end, type);
if (
mSpansArr.length == 0 || // We have no optimized spans
isExcludedSpanType(type)) { // Query is about unoptimized span
return spansFromSuperclass;
}
// Based on Arrays.binarySearch()
int lo = 0;
int hi = mSpansArr.length - 1;
int mid = -2;
while (lo <= hi) {
mid = (lo + hi) >>> 1;
int midVal = mSpansArr[mid].end;
if (midVal < start) {
lo = mid + 1;
} else if (midVal > start) {
hi = mid - 1;
} else {
break;
}
}
// Iterate over spans in range
List<T> result = null;
for (; mid < mSpansArr.length && mSpansArr[mid].start < end; mid++) {
if (mSpansArr[mid].end > start && type.isInstance(mSpansArr[mid].span)) {
if (result == null) {
result = LIST_POOL.acquire();
if (spansFromSuperclass.length != 0) {
result.addAll(Arrays.asList(spansFromSuperclass));
}
}
result.add((T) mSpansArr[mid].span);
}
}
// If we have list then make array and pass to superclass
if (result == null) {
return spansFromSuperclass;
} else {
T[] resultArray = result.toArray((T[]) Array.newInstance(type, result.size()));
LIST_POOL.release(result);
return resultArray;
}
}