SuperTextView

    SuperTextView 是TextView的升级版,可以实现TextView的全部功能,但SuperTextView比TextView的功能更加强大,在此空间中可以将文字,图片,其他控件(如CheckBox)等。

    先来看一下效果

      SuperTextView_第1张图片

    一.在module的build.gradle中添加依赖

compile 'com.allen.supertextview:supertextview:1.0.1'

    二.XML布局




    

    


    三.Java代码

public class MainActivity extends AppCompatActivity {

    private SuperTextView superTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        superTextView= (SuperTextView) findViewById(R.id.main_super_textView);
        //设置其一些属性
        superTextView.setCbChecked(true)
                .setLeftBottomString("建设银行");
//                .setLeftString("hahaha")
//                .setLeftTVColor(10);
//                .setLeftTopString("")
//                .setLeftTopTVColor(Color.GREEN);
//                .setLeftBottomString("")
//                .setLeftBottomTVColor(0)
//                .setLeftBottomString2("")
//                .setLeftBottomTVColor2(0)
//                .setRightString("")
//                .setRightTVColor(0)
//                .setCbChecked(true)
//                .setRightString("")
//                .setRightTVColor(0)
//                .setLeftString("");
        //设置监听器
        superTextView.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener(){

            //点击整个SuperTextView时回调
            @Override
            public void onSuperTextViewClick() {
                super.onSuperTextViewClick();
                //do SomeThing
            }

            //点击左上角时回调
            @Override
            public void onLeftTopClick() {
                super.onLeftTopClick();
                //do SomeThing
            }

            //点击左下角时回调
            @Override
            public void onLeftBottomClick() {
                super.onLeftBottomClick();
                //do SomeThing
            }

            //点击左下角时回调
            @Override
            public void onLeftBottomClick2() {
                super.onLeftBottomClick2();
                //do SomeThing
            }
        });
    }
}


你可能感兴趣的:(学习交流)