public class SpannableString {
public void setSpan(Object what, int start, int end, int flags) {
super.setSpan(what, start, end, flags);
}
}
SpannableString四个参数含义:
参数 | 含义 |
---|---|
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;
}
当在被选中文字左右插入文字时, 插入字段是否也会应用该样式;
参数 | 含义 |
---|---|
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