Giter Club home page Giter Club logo

smarttextview's Introduction

SmartTextView

一个聪明的TextView 1.0.1版本已经可以实现对于一段文字中的部分文字更改字体颜色,以及添加点击事件。

一.需要将strings.xml文件中的文字通过"(-"和"-)"包起来。

例如 (-S-)mart(-T-)ext(-V-)(-iew-)

二.通过SmartText添加SmartTextStyle对"(- -)"里面中的内容设置颜色 以及增加点击事件。

点击事件和文字下划线都是可选功能,如下所示

SmartText smartText = new SmartText(tv1, getResources().getString(R.string.SmartTextView));
        smartText
                .addTextStyle(new SmartTextStyle()
                                .setTextColor(getResources().getColor(R.color.colorPrimary))
                )
                .addTextStyle(new SmartTextStyle()
                        .setTextColor(getResources().getColor(R.color.colorPrimaryDark))
                        .setListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                Toast.makeText(MainActivity.this, "我可以点!!!", Toast.LENGTH_LONG).show();
                            }
                        })
                        .setWithUnderLine(true)
                )
                .addTextStyle(
                        new SmartTextStyle().setTextColor(getResources().getColor(R.color.dark))
                        .setListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                Toast.makeText(MainActivity.this, "我不能点啊为什么点我,哼!!!", Toast.LENGTH_LONG).show();
                            }
                        })
                )
//                .addTextStyle(new SmartTextStyle().setTextColor(getResources().getColor(R.color.colorPrimaryDark)))
                .finish();

smarttextview's People

Contributors

liuchch avatar

Stargazers

 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.