Skip to content

一个Android SpannableStringBuilder 快速构建工具,可以让你用链式表达式,快速写出想要的效果

License

Notifications You must be signed in to change notification settings

xujinyang/AndroidSpan

Repository files navigation

#AndroidSpan The AndroidSpan is a tool library for easy to use Android SpannableStringBuilder

#Demo demo

#Usage

#Gradle

dependencies {
   compile 'com.xujinyang.AndroidSpan:library:1.0.2'
}
Use it in your own code:
  AndroidSpan androidSpan = new AndroidSpan()
                .drawUnderlineSpan("测试文本")
                .drawRelativeSize("我要变大", 2.0f)
                .drawForegroundColor("红色的文本", Color.RED)
                .drawImageSpan("来个图片试试", getApplicationContext(), R.mipmap.ic_launcher)
                .drawBulletSpan("bullet", 20, Color.GREEN)
                .drawURLSpan("tel:18721850636")
                .drawStrikethroughSpan("删除线")
                .drawURLSpan("http://www.baidu.com")
                .drawStyleSpan("粗体", android.graphics.Typeface.BOLD)
                .drawSubscriptSpan("上标")
                .drawSuperscriptSpan("下标")
                .drawMaskFilterSpan("模糊效果", 1f, BlurMaskFilter.Blur.NORMAL)
                .drawWithOptions("点击效果", new SpanOptions().addSpan(new ClickableSpan() {
                    @Override
                    public void onClick(View view) {
                        Toast.makeText(getApplicationContext(), "哎呦,疼", Toast.LENGTH_LONG).show();
                    }
                }))
                .drawWithOptions("综合效果", new SpanOptions().addBackgroundColorSpan(Color.GREEN).addUnderlineSpan())
                .drawWithOptions("tel:18721850636", new SpanOptions().addForegroundColor(Color.GREEN));

        textView.setText(androidSpan.getSpanText());
        textView.setMovementMethod(LinkMovementMethod.getInstance());
you will see the demo picture

About

一个Android SpannableStringBuilder 快速构建工具,可以让你用链式表达式,快速写出想要的效果

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages