public class SpannableString {
public void setSpan(Object what, int start, int end, int flags) {
super.setSpan(what, start, end, flags);
}
}
SpannableString四個參數(shù)含義:
參數(shù) | 含義 |
---|---|
Object | 泛型, 可以設置顏色, 間距, 點擊事件等 |
int | 目標文字的起始點 |
int | 目標文字的終點 |
int | 其他文字效果 |
flags對應四個值:
public interface Spanned {
/**
* Non-0-length spans of type SPAN_INCLUSIVE_EXCLUSIVE expand
* to include text inserted at their starting point but not at their
* ending point. When 0-length, they behave like marks.
*/
public static final int SPAN_INCLUSIVE_EXCLUSIVE = SPAN_MARK_MARK;
/**
* Spans of type SPAN_INCLUSIVE_INCLUSIVE expand
* to include text inserted at either their starting or ending point.
*/
public static final int SPAN_INCLUSIVE_INCLUSIVE = SPAN_MARK_POINT;
/**
* Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand
* to include text inserted at either their starting or ending point.
* They can never have a length of 0 and are automatically removed
* from the buffer if all the text they cover is removed.
*/
public static final int SPAN_EXCLUSIVE_EXCLUSIVE = SPAN_POINT_MARK;
/**
* Non-0-length spans of type SPAN_EXCLUSIVE_INCLUSIVE expand
* to include text inserted at their ending point but not at their
* starting point. When 0-length, they behave like points.
*/
public static final int SPAN_EXCLUSIVE_INCLUSIVE = SPAN_POINT_POINT;
}
當在被選中文字左右插入文字時, 插入字段是否也會應用該樣式;
參數(shù) | 含義 |
---|---|
SPAN_INCLUSIVE_EXCLUSIVE | 包前不包后 |
SPAN_INCLUSIVE_EXCLUSIVE | 包前包后 |
SPAN_EXCLUSIVE_EXCLUSIVE | 不包前不包后 |
SPAN_EXCLUSIVE_INCLUSIVE | 不包前包后 |
http://blog.csdn.net/jdsjlzx/article/details/19122103
http://www.jb51.net/article/104028.htm
http://blog.csdn.net/qq_16430735/article/details/50427978#textappearancespan