SuperTextView 是一个功能强大的 View,可以满足日常大部分布局样式,开发者可已自行组合属性配置出属于自己风格的样式!可能描述起来没有概念,还是直接看效果图吧!
1,效果图:
这里写图片描述 这里写图片描述
这里写图片描述 这里写图片描述
这里写图片描述 这里写图片描述
2,如何使用
Android Studio导入方法,添加Gradle依赖
先在项目根目录的 build.gradle 的 repositories 添加:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
然后在dependencies添加:
dependencies {
...
compile 'com.github.lygttpod:SuperTextView:1.1.2'
}
2.1 布局中如何使用
<com.allen.supertextviewlibrary.SuperTextView
android:id="@+id/super_tv"
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sLeftBottomTextColor2="@color/colorAccent"
stv:sLeftBottomTextString="招商银行(8888)"
stv:sLeftBottomTextString2="限额说明>>"
stv:sLeftIconRes="@drawable/bank_zhao_shang"
stv:sLeftTopTextString="银行卡支付"
stv:sRightCheckBoxRes="@drawable/circular_check_bg"
stv:sRightCheckBoxShow="true"
stv:sLineShow="bottom"
/>
注意:
1、上下的线可以通过 sLineShow 设置 有四种显示方式 none,top,bottom,both
2、通过设置 sUseRipple=true 开启水波效果
示列:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:stv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftTextString="帐号管理"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftTextString="通知设置"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="通用设置"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="隐私与安全"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="设置中心"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftTextString="意见反馈"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="关于微博"
stv:sRightIconRes="@drawable/arrow_right_red" />
</LinearLayout>
</ScrollView>
</LinearLayout>
2.2 代码中如何使用:
/**
* 可以通过链式设置大部分常用的属性值
*/
superTextView.setLeftIcon(drawable)
.setLeftString("")
.setLeftTVColor(0)
.setLeftTopString("")
.setLeftTopTVColor(0)
.setLeftBottomString("")
.setLeftBottomTVColor(0)
.setLeftBottomString2("")
.setLeftBottomTVColor2(0)
.setRightString("")
.setRightTVColor(0)
.setCbChecked(true)
.setCbBackground(drawable)
.setRightIcon(drawable)
.setRightString("")
.setRightTVColor(0)
.setLeftString("")
//点击事件:
superTextView.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@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
}
});
注意:点击事件需要配合属性值使用
sLeftTopViewIsClickable= true
sLeftBottomViewIsClickable= true
sLeftBottomView2IsClickable= true
2.3 属性说明
这里写图片描述
这里写图片描述
3 效果图的布局:
activity_demo_one.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:stv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftTextString="帐号管理"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftTextString="通知设置"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="通用设置"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="隐私与安全"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="设置中心"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftTextString="意见反馈"
stv:sRightIconRes="@drawable/arrow_right_red" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftTextString="关于微博"
stv:sRightIconRes="@drawable/arrow_right_red" />
</LinearLayout>
</ScrollView>
</LinearLayout>
activity_demo_two.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:stv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:orientation="vertical">
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftIconRes="@drawable/uu"
stv:sBottomLineMargin="0dp"
stv:sLeftTextString="收货地址" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftIconRes="@drawable/uy"
stv:sBottomLineMargin="0dp"
stv:sLeftTextString="我的收藏" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftIconRes="@drawable/uv"
stv:sBottomLineMargin="0dp"
stv:sLeftTextString="美食相册" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sLeftIconRes="@drawable/v0"
stv:sBottomLineMargin="0dp"
stv:sLeftTextString="积分商城" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftIconRes="@drawable/v1"
stv:sBottomLineMargin="0dp"
stv:sLeftTextString="会员中心" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sLeftIconRes="@drawable/v2"
stv:sBottomLineMargin="0dp"
stv:sLeftTextString="加盟合作" />
</LinearLayout>
activity_demo_three.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:stv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:orientation="vertical">
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
stv:sBottomLineMargin="0dp"
stv:sLeftIconRes="@drawable/scatter_time"
stv:sIsSingLines="true"
stv:sLeftTextString="起息时间"
stv:sRightTextString="立即起息" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sLeftIconRes="@drawable/scatter_type"
stv:sLeftTextString="还款方式"
stv:sRightTextString="等额本息" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sLeftIconRes="@drawable/scatter_use"
stv:sLeftTextString="投标截止"
stv:sRightTextString="2016-10-19 08:00" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sLeftIconRes="@drawable/scatter_money"
stv:sLeftTextString="提前还款费率"
stv:sRightTextString="0.00%" />
</LinearLayout>
activity_demo_four.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:stv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:orientation="vertical">
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sCenterTextString="投资时间"
stv:sLeftTextString="投资人"
stv:sRightTextString="投资金额" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sCenterTextString="10:20"
stv:sLeftTextColor="@color/colorAccent"
stv:sLeftTextString="188******8888"
stv:sRightTextString="100元" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sCenterTextString="10:20"
stv:sLeftTextColor="@color/colorAccent"
stv:sLeftTextString="188******8888"
stv:sRightTextString="100元" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sCenterTextString="10:20"
stv:sLeftTextColor="@color/colorAccent"
stv:sLeftTextString="188******8888"
stv:sRightTextString="100元" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sCenterTextString="10:20"
stv:sLeftTextColor="@color/colorAccent"
stv:sLeftTextString="188******8888"
stv:sRightTextString="100元" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="50dp"
stv:sBottomLineMargin="0dp"
stv:sCenterTextString="10:20"
stv:sLeftTextColor="@color/colorAccent"
stv:sLeftTextString="188******8888"
stv:sRightTextString="100元" />
</LinearLayout>
activity_demo_five.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:stv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:orientation="vertical">
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sLeftBottomTextString="188****8888"
stv:sLeftIconRes="@drawable/head_default"
stv:sLeftTopTextString="张三" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sLeftBottomTextString="188****8888"
stv:sLeftIconRes="@drawable/head_default"
stv:sLeftTopTextString="张三" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sLeftBottomTextString="188****8888"
stv:sLeftIconRes="@drawable/head_default"
stv:sLeftTopTextString="张三" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
stv:sCenterTextString="下边展示使用网络图片的情况"
android:layout_height="50dp"/>
<com.allen.library.SuperTextView
android:id="@+id/super_tv1"
android:layout_width="match_parent"
android:layout_height="80dp" />
<com.allen.library.SuperTextView
android:id="@+id/super_tv2"
android:layout_width="match_parent"
android:layout_height="80dp" />
</LinearLayout>
activity_demo_six.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:stv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
android:orientation="vertical">
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sLeftBottomTextColor2="@color/colorAccent"
stv:sLeftBottomTextString="招商银行(8888)"
stv:sLeftBottomTextString2="限额说明>>"
stv:sLeftIconRes="@drawable/bank_zhao_shang"
stv:sLeftTopTextString="银行卡支付"
stv:sRightCheckBoxRes="@drawable/circular_check_bg"
stv:sRightCheckBoxShow="true" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sLeftBottomTextColor2="@color/colorAccent"
stv:sLeftBottomTextString="可用余额"
stv:sLeftBottomTextString2="8888元"
stv:sLeftIconRes="@drawable/balance_icon"
stv:sLeftTopTextString="余额支付"
stv:sRightCheckBoxRes="@drawable/circular_check_bg"
stv:sRightCheckBoxShow="true" />
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="50dp"
stv:sLeftBottomTextColor="@color/colorAccent"
stv:sLeftBottomTextString="限额说明>>"
stv:sLeftIconRes="@drawable/not_bank_card_icon"
stv:sLeftTopTextString="银行卡支付" />
</LinearLayout>
网友评论