Android自定义上拉控件SpringView
Demo
先看一下SpringView的效果图:

1.拖动灰色部分可拖动下方视图,点击jump按钮可让下方视图自行滑动。
使用方法
布局文件:
<com.zql.android.springview.SpringView
android:id="@+id/spring"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#ff5533ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="30sp"
android:text="First View"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:background="#ffeeeeee">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="I am move holder"
android:gravity="center"
android:layout_centerInParent="true"
android:layout_gravity="left"/>
<Button
android:id="@+id/jump"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:text="jump"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#ff553300">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="30sp"
android:text="Second View"/>
</LinearLayout>
</com.zql.android.springview.SpringView>
SpringView内部可以容纳两个或三个子view,当只有两个的时候,SringView会自动生成一个供拖拽的视图,当有三个的时候,会把第二个子view作为拖拽视图使用。建议使用三个子view,这样可以自定义拖拽的视图。
注意点:当使用三个子view的时候,第二个作为拖拽视图的布局要明确layout_height,不能使用match_parent或wrap_content。
SpringView的事件响应
public interface OnSpringListener{
//达到顶部时回调
void touchTop();
//达到底部时回调
void touchBottom();
}
SpringView自动滑动:
public void SpringView.jumpUp();
public void SpringView.jumpDown()
github
https://github.com/ZhangQinglian/Android-SpringView
Android自定义上拉控件SpringView的更多相关文章
- android 自定义空间 组合控件中 TextView 不支持drawableLeft属性
android 自定义空间 组合控件中 TextView 不支持drawableLeft属性.会报错Caused by: android.view.InflateException: Binary X ...
- (转载)Android自定义标签列表控件LabelsView解析
Android自定义标签列表控件LabelsView解析 作者 donkingliang 关注 2017.03.15 20:59* 字数 759 阅读 406评论 0喜欢 3 无论是在移动端的App, ...
- 自定义上传控件(兼容IE8)
上传控件是 <input type="file"/> 而实际开发过程中,都会自定义一个控件,因为这个控件本身难看,而且不同浏览器效果不一样. 如IE8显示如下: 谷歌浏 ...
- Android 自定义View修炼-如何打造Android自定义的下拉列表框控件
一.概述 Android中的有个原生的下拉列表控件Spinner,但是这个控件有时候不符合我们自己的要求, 比如有时候我们需要类似windows 或者web网页中常见的那种下拉列表控件,类似下图这样的 ...
- Android自定义View和控件之一-定制属于自己的UI
照例,拿来主义.我的学习是基于下面的三篇blog.前两是基本的流程,第三篇里有比较细致的绘制相关的属性.第4篇介绍了如何减少布局层次来提高效率. 1. 教你搞定Android自定义View 2. 教你 ...
- Android自定义控件进阶-打造Android自定义的下拉列表框控件
技术:Android+java 概述 Android中的有个原生的下拉列表控件Spinner,但是这个控件有时候不符合我们自己的要求, 比如有时候我们需要类似windows 或者web网页中常见的 ...
- Android 如何打造Android自定义的下拉列表框控件
一.概述 Android中的有个原生的下拉列表控件Spinner,但是这个控件有时候不符合我们自己的要求, 比如有时候我们需要类似windows 或者web网页中常见的那种下拉列表控件,类似下图这样的 ...
- Android自定义标签列表控件LabelsView解析
版权声明:本文为博主原创文章,未经博主允许不得转载. 无论是在移动端的App,还是在前端的网页,我们经常会看到下面这种标签的列表效果: 标签从左到右摆放,一行显示不下时自动换行.这样的效果用And ...
- [转]android 自定义圆形imageview控件
android布局 首先,定义定义圆形Imageview类: import android.content.Context; import android.graphics.Bitmap; imp ...
随机推荐
- MongoDB Query 判断为空 取值为空的时间
if (!string.IsNullOrEmpty(STATES)) { DateTime? dtnull = null; //Return if (STATES == "Return&qu ...
- 运行百度语音识别官方iOS demo报错: load offline engine failed: 4001
运行官方BDVRClientSample这个demo(ios版的),demo可以安到手机上,但是点“识别UI”那个按钮后“授权验证失败”.如果点“语音识别”那个按钮,控制台输出:2015-10-23 ...
- [获取行数]php读取大文件提供性能的方法,PHP的stream_get_line函数读取大文件获取文件的行数的方...
背景: 下面是获取文件的行数的方法: 一个文件如果知道有几行的话,就可以控制获取一定的行数的数据,然后放入数据库.这样不管的读取大文件的性能,还是写入数据库的性能,都能得到很大的提高了. 下面是获取文 ...
- 将HG版本库推送到Git服务器
如何将HG版本库推送到Git服务器? 目的 习惯使用HG来进行版本管理,但是GitHub代码统计比Bitbucket要丰富,所以准备主力仓库选用Bitbucket,GitHub作为备用仓库. GitH ...
- 在ubuntu上使用Virtual-Box安装Mininet
使用Virtual-Box安装Mininet看上去简单,但其中也暗藏许多坑.我自己装了多次Mininet,但每次都有缺陷: mininet访问不了网络 用宿主机访问不了mininet虚拟机 最后,终于 ...
- Atitit.软件开发的几大规则,法则,与原则p821.doc
Atitit.软件开发的几大规则,法则,与原则p821.doc 1. 设计模式六大原则2 1.1. 设计模式六大原则(1):单一职责原则2 1.2. 设计模式六大原则(2):里氏替换原则2 1.3. ...
- [position]返回顶部
position:fixed;实现 <!DOCTYPE html> <html lang="en"> <head> <meta chars ...
- DB2字符处理函数
转自:http://www.blogjava.net/bingle/archive/2007/07/11/129681.html ----------------------------------- ...
- Redis_发布订阅(Spring Boot)
目录 前言 生产者和消费者 发布和订阅 Java实现 注意 转至 http://www.tianmaying.com/tutorial/springboot-redis-message 前言 利用Sp ...
- ZOJ 3703 Happy Programming Contest(0-1背包)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3703 Happy Programming Contest Time Lim ...