在GitHub上的Android开源代码SuperTextView的使用
来源:互联网 发布:华夏幸福和知合控股 编辑:程序博客网 时间:2024/05/16 18:57
每周一会分享一篇GitHub开源的项目
SuperTextView
一个功能强大的TextView,可以满足日常大部分布局方式,开发者可已自行组合属性配置出属于自己风格的样式!
效果图
基本使用
1.添加Gradle依赖
先在 build.gradle 的 repositories 添加:
allprojects { repositories { ... maven { url "https://jitpack.io" } }}
然后在dependencies添加:
dependencies { ... compile 'com.allen.supertextview:supertextview:1.0.3' }
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>
6.使用第三方库(Picasso或者Glide)加载网络图片
Picasso.with(this) .load(url) .placeholder(R.drawable.head_default) .into((ImageView) superTextView.getView(SuperTextView.leftImageViewId));
获取更多或者转载请联系作者:QQ群322814924
关注下面订阅号可获取最新的全套Android学习视频
http://mp.weixin.qq.com/s?__biz=MzI0NDYzMzg0OQ==&mid=2247483715&idx=1&sn=afd9b944088ab259e69063780e69b72e&chksm=e95b98d5de2c11c3552e6b7ae571a3a635737097abc550f2e3532b88b7e8552e417938e37ef1&mpshare=1&scene=23&srcid=1107PLUws0A48nWoyc3ip2Jh#rd
0 0
- 在GitHub上的Android开源代码SuperTextView的使用
- github上开源代码在android studio上的使用
- 在Windows操作系统下下载github上的开源代码
- SuperTextView 一款强大的android TextView
- 大公司在github的开源代码
- 下载 https://github.com/android 上的全部源代码
- 下载 https://github.com/android 上的全部源代码
- superTextView 万能的TextView
- SuperTextView遇到的坑
- SuperTextView 强大的textView
- github在linux上的使用
- github在linux上的使用
- 在 MacOS 上简单的使用 GitHub
- 在 Windows 上简单的使用 GitHub
- 在GitHub上下载开源代码方法
- [版本控制]如何在GitHub上下载自己喜欢的开源代码并提交修改
- 如何在GitHub上下载自己喜欢的开源代码并提交修改
- [版本控制]如何在GitHub上下载自己喜欢的开源代码并提交修改
- Twisted学习(一)----------------------Deffered参考
- 内存映射mmap
- 浮点型数据存储方式
- 实用Linux命令
- 学习历程,数组,控制台输入数组并逆序输出
- 在GitHub上的Android开源代码SuperTextView的使用
- react异步方案实践
- 20161107学习心得
- 冒泡排序
- linux客户端与主机通信
- js 继承
- window.location.Reload()和window.location.href 区别
- Python-正则表达式多次匹配
- C++的文件操作