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的更多相关文章

  1. android 自定义空间 组合控件中 TextView 不支持drawableLeft属性

    android 自定义空间 组合控件中 TextView 不支持drawableLeft属性.会报错Caused by: android.view.InflateException: Binary X ...

  2. (转载)Android自定义标签列表控件LabelsView解析

    Android自定义标签列表控件LabelsView解析 作者 donkingliang 关注 2017.03.15 20:59* 字数 759 阅读 406评论 0喜欢 3 无论是在移动端的App, ...

  3. 自定义上传控件(兼容IE8)

    上传控件是 <input type="file"/> 而实际开发过程中,都会自定义一个控件,因为这个控件本身难看,而且不同浏览器效果不一样. 如IE8显示如下: 谷歌浏 ...

  4. Android 自定义View修炼-如何打造Android自定义的下拉列表框控件

    一.概述 Android中的有个原生的下拉列表控件Spinner,但是这个控件有时候不符合我们自己的要求, 比如有时候我们需要类似windows 或者web网页中常见的那种下拉列表控件,类似下图这样的 ...

  5. Android自定义View和控件之一-定制属于自己的UI

    照例,拿来主义.我的学习是基于下面的三篇blog.前两是基本的流程,第三篇里有比较细致的绘制相关的属性.第4篇介绍了如何减少布局层次来提高效率. 1. 教你搞定Android自定义View 2. 教你 ...

  6. Android自定义控件进阶-打造Android自定义的下拉列表框控件

    技术:Android+java   概述 Android中的有个原生的下拉列表控件Spinner,但是这个控件有时候不符合我们自己的要求, 比如有时候我们需要类似windows 或者web网页中常见的 ...

  7. Android 如何打造Android自定义的下拉列表框控件

    一.概述 Android中的有个原生的下拉列表控件Spinner,但是这个控件有时候不符合我们自己的要求, 比如有时候我们需要类似windows 或者web网页中常见的那种下拉列表控件,类似下图这样的 ...

  8. Android自定义标签列表控件LabelsView解析

    版权声明:本文为博主原创文章,未经博主允许不得转载. 无论是在移动端的App,还是在前端的网页,我们经常会看到下面这种标签的列表效果:   标签从左到右摆放,一行显示不下时自动换行.这样的效果用And ...

  9. [转]android 自定义圆形imageview控件

      android布局 首先,定义定义圆形Imageview类: import android.content.Context; import android.graphics.Bitmap; imp ...

随机推荐

  1. 前端JS脚本将网页表格导出为Excel

    话不多说,上代码! <!DOCTYPE> <html> <head> <title>Excel Test</title> </head ...

  2. LNMP架构四

    php-fpm的pool(连接池) 我们查看php的进程时,会发现,在最后一个pool的选项,而这个就是我们在php-fpm配置文件里写的一个连接池. [root@bogon linux.com]# ...

  3. MDK5.00中*** error 65: access violation at 0xFFFFFFFC : no 'write' permission的一种解决方法

    http://blog.csdn.net/coderfun/article/details/9417289 这是在调试过程中的修改方法,所以在每次运行的时候,都要设置. 先进入调试模式(crtl+F5 ...

  4. wxpy学习

    准备工作 安装 pip install -U wxpy -i "https://pypi.doubanio.com/simple/" 通过python脚本来发送消息给好友 from ...

  5. 基于部标Jt/T809协议和Java Netty框架构建Gps位置监控平台

    现在地方上由于运输车辆的GPS数据都分散在地方上已有的各种企业平台上面,不利于大数据的分析和智能应用,而开发智能的基于大数据的Gps监控平台,往往需要和各种第三方的部标GPS监控平台对接,获取到第三方 ...

  6. Windows虚拟环境下安装mysql-python

    因为在虚拟环境下安装mysql-python走了许多弯路,特此记录,也希望以后的朋友避免像我一样,被环境配置问题搞的半死 直接使用pip安装mysql-python会报错 pip install My ...

  7. c# 多线程里面创建byte数组发生内存溢出异常求解

    在多线程里面读取一个400多M的Xml文件,首先将其读入FileStream里面,然后,在执行 byte [] bts = new byte[fs.Length]; 这句代码时,出现内存溢出的异常,求 ...

  8. ubox及日志管理

    ubox是openwrt的帮助工具箱,位于代码package/system/ubox下, CMakeLists.txt kmodloader.c log/ lsbloader.c validate/ ...

  9. 线程池 (thread pool) 的类型与实现方式

    在许多应用中需要频繁的创建许多生命周期很短的线程,如果用传统方法的话就会造成大量的资源了浪费,java的设计者们考虑到了这点在java中加入了线程池这个特性,它负责管理大量的线程的创建销毁等操作. 首 ...

  10. Android Studio无法启动,gradle下载不了 提示“building “ 项目名”gradle project info”

    Google在2013年I/O大会上发布了Android Studio,AndroidStudio是一个基于IntelliJ思想的新的Android开发工具.下面介绍一下Android Studio安 ...