Coder Social home page Coder Social logo

texttagspan's Introduction

TextTagSpan

在TextView中使用文本添加自定义标签

image

支持:

  1. 可在文本任何位置添加文字标签
  2. 标签可设置文字大小、文字颜色、边框颜色、边框宽度、边框圆角
  3. 标签也可直接设置drawable背景
  4. 边框可设置左右间距
  5. 支持设置行间距后,每一行标签都居中显示。

使用

TextTagSpan构造方法指定宽高,可使用drawable作为背景

 TextTagSpan span = new TextTagSpan(this, dip2px(25), dip2px(15))
                .setRightMargin(dip2px(5))
                .setTextColor(Color.BLACK)
                .setTextSize(sp2px(11))
                .setBackground(R.drawable.tag_bacground);

也可直接设置背景边框颜色、边框宽度和圆角

TextTagSpan span = new TextTagSpan(this, dip2px(25), dip2px(15))
                .setLeftMargin(dip2px(5))
                .setTextColor(Color.RED)
                .setTextSize(sp2px(13))
                .setRadius(dip2px(3))
                .setStrokeWidth(dip2px(0.5f))
                .setStrokeColor(Color.RED);

结合Truss使用更加方便。Truss使用参考:https://gist.github.com/JakeWharton/11274467

texttagspan's People

Contributors

sixgodit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.