一个功能强大的 TextView,可以满足日常大部分布局方式,开发者可已自行组合属性配置出属于自己风格的样式!
2016-10-28 15:59
507 查看
SuperTextView
项目地址:lygttpod/SuperTextView![](https://oscdn.geek-share.com/Uploads/Images/Content/201606/7d0234f6040bfebfea82f8d6092495f1.png)
简介:一个功能强大的 TextView,可以满足日常大部分布局方式,开发者可已自行组合属性配置出属于自己风格的样式!一个功能强大的 TextView,可以满足日常大部分布局方式,开发者可已自行组合属性配置出属于自己风格的样式!
效果图
![](https://raw.githubusercontent.com/lygttpod/SuperTextView/master/screenshot.png)
![](https://raw.githubusercontent.com/lygttpod/SuperTextView/master/type1.png)
![](https://raw.githubusercontent.com/lygttpod/SuperTextView/master/type2.png)
![](https://raw.githubusercontent.com/lygttpod/SuperTextView/master/type3.png)
![](https://raw.githubusercontent.com/lygttpod/SuperTextView/master/type4.png)
![](https://raw.githubusercontent.com/lygttpod/SuperTextView/master/type5.png)
![](https://raw.githubusercontent.com/lygttpod/SuperTextView/master/type6.png)
基本使用
1.添加 Gradle 依赖
dependencies { ... compile 'com.allen.supertextview:supertextview:1.0.1' }
2.布局中如何使用
<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 开启水波效果
3.代码中如何使用
/** * 可以通过链式设置大部分常用的属性值 */ 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("") .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 } });
4.点击事件(可根据需求选择实现某个点击事件)
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 } });
5.属性说明(以下属性全部可以通过 xml 文件配置和代码进行设置)
<declare-styleable name="SuperTextView"> <attr name="sLeftIconRes" format="reference"/> <attr name="sRightIconRes" format="reference"/> <attr name="sRightCheckBoxRes" format="reference"/> <attr name="sLeftTextString" format="string"/> <attr name="sCenterTextString" format="string"/> <attr name="sRightTextString" format="string"/> <attr name="sLeftTopTextString" format="string"/> <attr name="sLeftBottomTextString" format="string"/> <attr name="sLeftBottomTextString2" format="string"/> <attr name="sTopLineMargin" format="dimension"/> <attr name="sBottomLineMargin" format="dimension"/> <attr name="sBothLineMargin" format="dimension"/> <attr name="sLeftIconMarginLeft" format="dimension"/> <attr name="sLeftTextMarginLeft" format="dimension"/> <attr name="sLeftTopTextMarginLeft" format="dimension"/> <attr name="sLeftBottomTextMarginLeft" format="dimension"/> <attr name="sLeftBottomTextMarginLeft2" format="dimension"/> <attr name="sRightIconMarginRight" format="dimension"/> <attr name="sRightTextMarginRight" format="dimension"/> <attr name="sRightCheckBoxMarginRight" format="dimension"/> <attr name="sRightCheckBoxShow" format="boolean"/> <attr name="sIsChecked" format="boolean"/> <attr name="sUseRipple" format="boolean"/> <attr name="sLeftTextSize" format="dimension"/> <attr name="sLeftTopTextSize" format="dimension"/> <attr name="sLeftBottomTextSize" format="dimension"/> <attr name="sLeftBottomTextSize2" format="dimension"/> <attr name="sRightTextSize" format="dimension"/> <attr name="sCenterTextSize" format="dimension"/> <attr name="sBackgroundColor" format="color"/> <attr name="sLeftTextColor" format="color"/> <attr name="sLeftTopTextColor" format="color"/> <attr name="sLeftBottomTextColor" format="color"/> <attr name="sLeftBottomTextColor2" format="color"/> <attr name="sRightTextColor" format="color"/> <attr name="sCenterTextColor" format="color"/> <attr name="sLineShow" format="enum"> <enum name="none" value="0"/> <enum name="top" value="1"/> <enum name="bottom" value="2"/> <enum name="both" value="3"/> </attr> </declare-styleable>
相关文章推荐
- Android:一个TextView分段改变样式、添加监听事件的实现方式(类似朋友圈评论)
- 实现【关于我们】功能(textview的文本样式几种实现方式)
- 一个类似于环形的 ProgressBar 的,可以自定义 Color,style 等属性的 View,支持 Material 风格.
- (android实战)实现【关于我们】功能(textview的文本样式几种实现方式)
- 分析 TextView 应用 Spannable 风格后 ellipsize 属性失效
- Android TextView设置字体风格多种组合
- (五)OpenCV提供一个功能强大的UI接口,可以在MFC、Qt、WinForms、Cocoa等平台下使用
- Flex中通过textAlign样式在一个按钮(Button)控件中设置标签(label)对齐方式的例子
- Android实战技巧:用TextView实现Rich Text---在同一个TextView中设置不同的字体风格
- Android 开发者,你真的会用textview(maxEms和maxLength)的属性吗?
- Android Layout 布局 && Android自带样式(theme)&& CheckBox样例 && View三种属性
- 用TextView实现Rich Text(富文本编辑器)---在同一个TextView中设置不同的字体风格
- 实现一个配置简单功能强大的excel工具类搞定excel导入导出(二)
- 同一个textview中设置字体不同样式
- Android实战技巧:用TextView实现Rich Text---在同一个TextView中设置不同的字体风格
- 设计并实现一个LogService,应用开发时可以打印log到视图(TextView)中显示
- Android实战技巧:用TextView实现Rich Text---在同一个TextView中设置不同的字体风格
- 用TextView实现Rich Text---在同一个TextView中设置不同的字体风格
- Android实战技巧:用TextView实现Rich Text---在同一个TextView中设置不同的字体风格
- Android实战技巧:用TextView实现Rich Text---在同一个TextView中设置不同的字体风格