Code Monkey home page Code Monkey logo

verticalslideview's Introduction

VerticalSlideView

###类似淘宝的商品详情页,继续拖动查看详情,其中拖动增加了阻尼,并且重写了ListView,GridView,ScrollView,WebView,RecyclerView 的 dispatchTouchEvent 方法,使用的时候无须额外的代码,可以任意嵌套使用。

该项目参考了:https://github.com/xmuSistone/android-vertical-slide-view 喜欢原作的可以去使用。相比原项目,代码更简单易懂,扩展性更高,欢迎大家下载体验本项目,如果使用过程中遇到什么问题,欢迎反馈。

联系方式

  • 邮箱地址: [email protected]
  • QQ群: 489873144 (建议使用QQ群,邮箱使用较少,可能看的不及时)
  • 本群刚建立,旨在为使用我的github项目的人提供方便,如果遇到问题欢迎在群里提问。个人能力也有限,希望一起学习一起进步。

演示

imageimageimageimage

1.用法

该项目和我github上其他的view相关的项目已经一起打包上传到jCenter仓库中(源码地址 https://github.com/jeasonlzy0216/ViewCore ),使用的时候可以直接使用compile依赖,用法如下

	compile 'com.lzy.widget:view-core:0.1.9'

或者使用

    compile project(':verticalslide')

2.实现原理

把ListView,GridView,ScrollView,WebView,RecyclerView 的 dispatchTouchEvent 方法进行重写,当这几个View在对顶部并且向下拉 或者 在对底部向上拉时,自身不消费事件,让父容器拦截事件并处理。并支持ViewPager。

3.代码参考

1.对于加载下一页的监听,只需要初始化控件并且设置监听即可

	DragSlideLayout dragLayout = (DragSlideLayout) findViewById(R.id.dragLayout);
	dragLayout.setOnShowNextPageListener(new DragSlideLayout.OnShowNextPageListener() {
        @Override
        public void onShowNextPage() {
            fragment_webView.initView();
        }
    });

2.使用DragSlideLayout控件,内部包含两个子View,分别表示第一页和第二页,可以先使用FrameLayout占位,代码中使用Fragment替换

	<?xml version="1.0" encoding="utf-8"?>
	<RelativeLayout
	    xmlns:android="http://schemas.android.com/apk/res/android"
	    android:layout_width="match_parent"
	    android:layout_height="match_parent">
	
	    <com.lzy.ui.DragSlideLayout
	        android:id="@+id/dragLayout"
	        android:layout_width="match_parent"
	        android:layout_height="match_parent">
	
	        <FrameLayout
	            android:id="@+id/first"
	            android:layout_width="match_parent"
	            android:layout_height="match_parent"/>
	
	        <FrameLayout
	            android:id="@+id/second"
	            android:layout_width="match_parent"
	            android:layout_height="match_parent"/>
	    </com.lzy.ui.DragSlideLayout>
	</RelativeLayout>

3.也可以直接使用VerticalScrollView,或者VerticalListView,等替换,上下两个布局可以任意调换

	<?xml version="1.0" encoding="utf-8"?>
	<RelativeLayout
	    xmlns:android="http://schemas.android.com/apk/res/android"
	    android:layout_width="match_parent"
	    android:layout_height="match_parent">
	
	    <com.lzy.ui.DragSlideLayout
	        android:id="@+id/dragLayout"
	        android:layout_width="match_parent"
	        android:layout_height="match_parent">
	
	        <com.lzy.ui.VerticalScrollView
			    android:id="@+id/custScrollView"
	            android:layout_width="match_parent"
	            android:layout_height="match_parent"
	            android:background="#fff"
	            android:orientation="vertical">
			
			    <LinearLayout
			        android:layout_width="match_parent"
			        android:layout_height="match_parent"
			        android:orientation="vertical">
					
					......

			    </LinearLayout>
			
			</com.lzy.ui.VerticalScrollView>
	
	        <com.lzy.ui.VerticalListView
		        android:id="@+id/listView"
		        android:layout_width="fill_parent"
		        android:layout_height="fill_parent" />

		</com.lzy.ui.DragSlideLayout>
	</RelativeLayout>

verticalslideview's People

Contributors

jeasonlzy avatar

Watchers

Atlantis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.