SpannableString

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容