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. 现在的C语言编辑器里的int范围为什么是-2147483648~2147483647 2014-08-05 10:21 100人阅读 评论(0) 收藏

    下面是引用百度文库的一段话: "这得从二进制的原码说起: 如果以最高位为符号位,二进制原码最大为0111111111111111=215-1=32767 最小为111111111111111 ...

  2. PHP 抽象类的使用

    //抽象类就是一个模版 abstract class db{ /* 参数:sql语句 返回值:索引的数组 */ abstract public function test($str); //没有方法体 ...

  3. 报错"the microsoft.jet.oledb.4.0 provider is not registered on the local machine"解决方案

    报错提示:"the microsoft.jet.oledb.4.0 provider is not registered on the local machine" 错误起因:wi ...

  4. void *指针的加减运算

    1.手工写了一个程序验证void *指针加减运算移动几个字节: //本程序验证空类型指针减1移动几个字节 #include <stdio.h> int main(int argc, cha ...

  5. atitit.信息系统方案规划 p71.doc

    [信息系统方案规划 ] 版本 v2 2015-7-1 变更记录 日期 修改人 版本 变更事由 说明 2015.07 艾龙 1.0 初创 2015.07 艾龙 2.0 添加接口 1. 业务功能与流程设计 ...

  6. JSON的String字符串与Java的List列表对象的相互转换

    1.JSON的String字符串与Java的List列表对象的相互转换 在前端: 1.如果json是List对象转换的,可以直接遍历json,读取数据. 2.如果是需要把前端的List对象转换为jso ...

  7. css断句 word-break

    word-break:break-all;word-wrap:break-word; 兼容IE6 火狐 chrome

  8. 在OrangePI上搭建homeassitant过程记录

    1.更换Python版本 由于在新版的homeassistant当中需要使用python3.5.3及以后的版本,但由于apt源中只包含3.5.2的版本,所以需要升级到python3.6. 具体更换方式 ...

  9. jquery datagrid设置pageSize不起作用

    http://www.2cto.com/kf/201212/178098.html —————————————————————————————————————————————————————————— ...

  10. Python之Matplotlib库常用函数大全(含注释)

    plt.savefig(‘test’, dpi = 600) :将绘制的图画保存成png格式,命名为 test plt.ylabel(‘Grade’) :  y轴的名称 plt.axis([-1, 1 ...