提交 56158b14 编写于 作者: C chaychan

更新README,添加NumberRunningTextView和ExpandableLinearLayout的介绍

上级 7c4e404d
# PowerfulViewLibrary
###PowerfulEditText具有的功能###
###PowerfulEditText介绍###
####1.自带清除文本功能 ####
  PowerfulEditText自带清除文本功能,只需在布局文件该View属性中添加funcType,指定为canClear,就可以自带清除文本功能,使用如下:
......@@ -135,7 +134,129 @@ Activity
  Activity中,为PowerfulEditText设置右侧图片的点击事件,调用setOnRightClickListener设置点击后的回调,这里点击后如果有文本内容,则执行搜索逻辑。
####导入方式####
  关于PowerfulEditText的源码解析可以观看我的博客 [http://blog.csdn.net/chay_chan/article/details/63685905](http://blog.csdn.net/chay_chan/article/details/63685905)
###NumberRunningTextView介绍
  NumberRunningTextView是一个自带数字滚动动画的TextView,通过使用setContent(String str)方法,传入相应的金额数字字符串(如"1354.00"),或者数字的字符串(如200),当页面初始化完成的时候,就可以看到数字滚动的效果,和支付宝中进入余额宝界面,显示余额滚动的效果类似,具体的效果如下:
![](./introduce_img/running_tv_1.gif)
###使用
在布局文件中,使用NumberRunningTextView,代码如下:
演示金额滚动的NumberRunningTextView
<com.chaychan.viewlib.NumberRunningTextView
android:id="@+id/tv_money"
android:layout_width="wrap_content"
android:layout_height="wrap_cointent"
android:layout_centerInParent="true"
android:text="0.00"
android:textColor="#fff"
android:textSize="30sp"
android:textStyle="bold"
/>
演示整数数字滚动的NumberRunningTextView
<com.chaychan.viewlib.NumberRunningTextView
android:id="@+id/tv_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="200"
android:textColor="#fff"
android:textSize="30sp"
app:textType="num"
/>
&emsp;&emsp;二者的区别在于textType的设置,textType是用于指定内容的格式,总共有money(金钱格式,带小数)和num(整数格式),默认是金钱的格式,不配置textType的话,默认就是使用金钱格式。
在java文件中根据id找到对应的view后,调用setContent()方法即可。
tvMoney.setContent("1354.00");
tvNum.setContent("200");
####关闭金额的自动格式化(每三位数字添加一个逗号)
&emsp;&emsp;上图所示,最后显示的金额数字经过了处理,每三位添加一个逗号,这使得数字看起来比较好看,金额默认是使用这种格式,如果不想要这种格式的数字,可以在布局文件中,NumberRunningTextView的配置中,将useCommaFormat设置为false,这样最终的数字就不会是带有逗号了,效果如下:
![](./introduce_img/running_tv_2.gif)
####关闭执行动画的时机
&emsp;&emsp;当一开始进入界面的时候,初始化数据完毕,NumberRunningTextView设置数据完毕,会自动执行数字滚动的动画,如果进行刷新操作,从服务器获取新的数据,重新设置数据,NumberRunningTextView会自动判断传入的内容是否有变化,如果没有变化,则不会再次滚动,这和支付宝的余额宝界面中的金额类似,当在余额宝界面下拉刷新时,金额没有变化,数字不会再次滚动,而当提现后重新回到该界面,金额发生变化后,就会再次滚动,效果如下:
![](./introduce_img/running_tv_3.gif)
SwipeRefreshLayout的刷新回调中,只做了这样的处理,NumberRunningTextView设置的内容还是原来的数据。
srlRoot.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
tvMoney.setContent("1354.00");
tvNum.setContent("200");
srlRoot.setRefreshing(false);
}
});
&emsp;&emsp;当你进行下拉刷新的时候,内容如果没有发生变化,数字是不会滚动的,如果内容发生变化,数字又会重新进行滚动,这里修改下拉刷新的代码,模拟数据变化的情况,演示一下:
srlRoot.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
tvMoney.setContent("1454.00");
tvNum.setContent("300");
srlRoot.setRefreshing(false);
}
});
效果如下:
![](./introduce_img/running_tv_4.gif)
&emsp;&emsp;如果想要在刷新的时候,无论内容是否有变化都要执行滚动动画的话,可以在布局文件中,NumberRunningTextView的配置中,将runWhenChange设置为false即可,此时,无论内容是否有变化,都会执行滚动动画,效果如下:
![](./introduce_img/running_tv_5.gif)
####修改帧数
&emsp;&emsp;NumberRunningTextView默认是30帧,如果需要修改帧数,可以在布局文件中,NumberRunningTextView的配置中,将frameNum设置为自己想要的帧数。
&emsp;&emsp;关于NumberRunningTextView的源码解析可以查看我的博客 [http://blog.csdn.net/chay_chan/article/details/70196478](http://blog.csdn.net/chay_chan/article/details/70196478)
##ExpandableLinearLayout介绍
&emsp;&emsp;ExpandableLinearLayout是一个可以展开全部和收起部分子条目的LinearLayout,可以指定默认展示前几个条目,点击查看全部则显示全部条目,效果如下:
![](./introduce_img/expandableLinearLayout.gif)
布局文件中配置,defaultItemCount为默认显示的条目数,expandText当处于展开时的文字提示,hideText当处于收起时的文字提示。
<com.chaychan.viewlib.ExpandableLinearLayout
android:id="@+id/ell_product"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
app:defaultItemCount="2"
app:expandText="收起内容"
app:hideText="查看更多"
>
</com.chaychan.viewlib.ExpandableLinearLayout>
代码中动态添加子条目
ExpandableLinearLayout ellProduct = (ExpandableLinearLayout) findViewById(R.id.ell_product);
for (int i = 0; i < 9; i++) {
View view = View.inflate(this, R.layout.item_product, null);
ellProduct.addItem(view);
}
####**导入方式**####
在项目根目录下的build.gradle中的allprojects{}中,添加jitpack仓库地址,如下:
allprojects {
......@@ -149,7 +270,5 @@ Activity
dependencies {
......
compile 'com.github.chaychan:PowerfulViewLibrary:1.0'
compile 'com.github.chaychan:PowerfulViewLibrary:1.1.0'
}
&emsp;&emsp;这样就可以使用PowerfulViewLibrary下的控件了,目前只对EditText的一些功能进行了封装,往后会把一些常用的View进行封装,方便项目的开发,我会保持对PowerfulViewLibrary的更新和维护的,也希望大家可以向我提出一些建议。
\ No newline at end of file
因为 它太大了无法显示 image diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册