SuperTextView

来源:互联网 发布:淘宝源码 编辑:程序博客网 时间:2024/06/05 19:19

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

    先来看一下效果

      

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

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

    二.XML布局

<?xml version="1.0" encoding="utf-8"?><RelativeLayout    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    xmlns:stv="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="zhiyuan3g.com.mysupertextview.MainActivity">    <com.allen.supertextviewlibrary.SuperTextView        android:id="@+id/main_super_textView"        android:layout_width="match_parent"        android:layout_height="100dp"        stv:sLeftBottomTextString="招商银行8888"        stv:sLeftBottomTextString2="限额说明"        stv:sLeftIconRes="@drawable/bank"        stv:sLeftTopTextString="银行卡支付"        stv:sRightCheckBoxRes="@drawable/circle_false"        stv:sRightCheckBoxShow="true"        stv:sLineShow="top"        >    </com.allen.supertextviewlibrary.SuperTextView></RelativeLayout>

    三.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            }        });    }}


0 0
原创粉丝点击