All Projects → JarvisGG → Nestedtouchscrollinglayout

JarvisGG / Nestedtouchscrollinglayout

Licence: mit
🎱处理子 View,父 View 嵌套滚动,成本比 support v4 NestedScrolling 低,放心食用~

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Nestedtouchscrollinglayout

bottomsheets
Material Bottom Sheets library for Android
Stars: ✭ 76 (-86.36%)
Mutual labels:  view, viewgroup
Slidemenulayout
🔥An android slide menu that supports left and right swipes and slides with parallax.(一个支持左右滑动并带有视差滑动效果的安卓侧滑菜单控件.仿[QQ/探探侧滑])
Stars: ✭ 235 (-57.81%)
Mutual labels:  view, viewgroup
Chips Input Layout
A customizable Android ViewGroup for displaying Chips (specified in the Material Design Guide).
Stars: ✭ 591 (+6.1%)
Mutual labels:  view, viewgroup
FlowlayoutTags
具有标签功能的流式布局,接口简单。可多选单选,可记住选择状态,状态切换有过渡动画。
Stars: ✭ 78 (-86%)
Mutual labels:  view, viewgroup
drag-to-close
Android library that provides a view group which allows to finish an activity by dragging a view.
Stars: ✭ 69 (-87.61%)
Mutual labels:  view, viewgroup
SlipperyLayout
A layout that supports sliding.
Stars: ✭ 44 (-92.1%)
Mutual labels:  view, viewgroup
Calendarview
Calendar View Library
Stars: ✭ 71 (-87.25%)
Mutual labels:  view, viewgroup
ShadowDrawable
为View 和 ViewGroup 添加阴影效果--Android,Add shadow for single view or viewgroup layout.
Stars: ✭ 22 (-96.05%)
Mutual labels:  view, viewgroup
CoolView
一些炫酷的自定义控件(Some cool custom controls),逐步完善中...
Stars: ✭ 63 (-88.69%)
Mutual labels:  view, viewgroup
bubble-layout
An Android ViewGroup that displays avatar bubbles... similar to the chat bubbles on Facebook Messenger.
Stars: ✭ 46 (-91.74%)
Mutual labels:  view, viewgroup
Materialtimelineview
With MaterialTimelineView you can easily create a material looking timeline.
Stars: ✭ 443 (-20.47%)
Mutual labels:  view
Edgetranslucent
Android 任意View边沿渐变透明
Stars: ✭ 461 (-17.24%)
Mutual labels:  view
Scrollbear
A modern tool that maintains scroll position when images loaded
Stars: ✭ 523 (-6.1%)
Mutual labels:  view
Tap
1Kb library for easy unified handling of user interactions such as mouse, touch and pointer events.
Stars: ✭ 541 (-2.87%)
Mutual labels:  touch-events
Sliding Panel
Android sliding panel that is part of the view hierarchy, not above it.
Stars: ✭ 433 (-22.26%)
Mutual labels:  viewgroup
Kotlinextensions.com
A handy collection of most commonly used Kotlin extensions to boost your productivity.
Stars: ✭ 522 (-6.28%)
Mutual labels:  viewgroup
Weatherview
WeatherView is an Android Library let you make cool weather animations for your app
Stars: ✭ 426 (-23.52%)
Mutual labels:  view
Mylinearlayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITab…
Stars: ✭ 4,152 (+645.42%)
Mutual labels:  view
Lemniscate
An easy way to make your progress view nice and sleek.
Stars: ✭ 420 (-24.6%)
Mutual labels:  view
Zloading
[Android] 这是一个自定义Loading View库。暂停更新
Stars: ✭ 552 (-0.9%)
Mutual labels:  view

NestedTouchScrollingLayout

Platform SDK

This layout is used to support dispatch touch event. There has some example gif~

主要用来做 View 的无缝拖拽,详细效果看 gif~


Author Jarvis
E-mail [email protected]

效果

demo1 demo2
normal webview
demo3 demo4
bottomsheet normal bottomsheet appbarlayout
demo8 demo9
webview recyclerview imageview recyclerview
demo6
scene1 scene2

Usage example

normal use

<jarvis.com.library.NestedTouchScrollingLayout
    android:id="@+id/wrapper"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/container_rv"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:background="#fff"
        android:overScrollMode="always">
    </android.support.v7.widget.RecyclerView>

</jarvis.com.library.NestedTouchScrollingLayout>
// 设置手指下拉阻尼
mNestedTouchScrollingLayout.setDampingDown(2.0f / 5);
// 设置手指上拉阻尼
mNestedTouchScrollingLayout.setDampingUp(3.0f / 5);

mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
        
        // 当前 Layout 偏移距离
	@Override
	public void onNestChildScrollChange(float deltaY, float velocityY) {

	}
	
	// finger 脱离屏幕 Layout 偏移量,以及当前 Layout 的速度
	@Override
	public void onNestChildScrollRelease(final float deltaY, final int velocityY) {
		mNestedTouchScrollingLayout.recover(0, new Runnable() {
			@Override
			public void run() {
				Log.i("NestedTouchScrollingLayout ---> ", "deltaY : " + deltaY + " velocityY : " + velocityY);
			}
		});
	}
	// 手指抬起时机
	@Override
	public void onFingerUp(float velocityY) {

	}

	// 横向拖拽
	@Override
	public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) {
	
	}
	
	// 当前 SheetView 运动状态
	@Override
    public void onNestScrollingState(int state) {

    }
});

bottomsheet use

 <jarvis.com.library.NestedTouchScrollingLayout
	android:id="@+id/wrapper"
	android:layout_marginTop="30dp"
	android:layout_width="match_parent"
	android:layout_height="match_parent">

	<android.support.v7.widget.RecyclerView
		android:background="#fff"
		android:id="@+id/container_rv"
		android:layout_width="match_parent"
		android:layout_height="match_parent" />

</jarvis.com.library.NestedTouchScrollingLayout>
// 临界速度,根据业务而定
public static int mVelocityYBound = 1300;

// 规定 sheetView 弹起方向
mNestedTouchScrollingLayout.setSheetDirection(NestedTouchScrollingLayout.SheetDirection.BOTTOM);

mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
	
	
	@Override
	public void onNestChildScrollChange(float deltaY, float velocityY) {

	}

	@Override
	public void onNestChildScrollRelease(float deltaY, int velocityY) {
		int totalYRange = mNestedTouchScrollingLayout.getMeasuredHeight();
		int helfLimit = (totalYRange - DisplayUtils.dpToPixel(BottomSheetActivity.this, 400)) / 2;
		int hideLimit = totalYRange - DisplayUtils.dpToPixel(BottomSheetActivity.this, 400) / 2;
		int helfHeight = totalYRange - DisplayUtils.dpToPixel(BottomSheetActivity.this, 400);
		if (velocityY > mVelocityYBound && velocityY > 0) {
			if (Math.abs(deltaY) > helfHeight) {
				mNestedTouchScrollingLayout.hiden();
			} else {
				mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(BottomSheetActivity.this,400));
			}
		} else if (velocityY < -mVelocityYBound && velocityY < 0) {
			if (Math.abs(deltaY) < helfHeight) {
				mNestedTouchScrollingLayout.expand();
			} else {
				mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(BottomSheetActivity.this,400));
			}
		} else {
			if (Math.abs(deltaY) > hideLimit) {
				mNestedTouchScrollingLayout.hiden();
			} else if (Math.abs(deltaY) > helfLimit) {
				mNestedTouchScrollingLayout.peek(mNestedTouchScrollingLayout.getMeasuredHeight() - DisplayUtils.dpToPixel(BottomSheetActivity.this, 400));
			} else {
				mNestedTouchScrollingLayout.expand();
			}
		}
	}

	@Override
	public void onFingerUp(float velocityY) {

	}

	@Override
	public void onNestChildHorizationScroll(MotionEvent event, float deltaX, float deltaY) {

	}
});

Next

  • [x] hold all touch event, and dispath touch event to child view.
  • [x] fix ACTION_UP dispatch child click event.
  • [x] support bottomsheet.
  • [x] support CoordinatorLayout (AppbarLayout).
  • [x] add damping draging.
  • [ ] add blur cover.

Usage

方式 1:

repositories {
    // ...
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation 'com.github.JarvisGG:NestedTouchScrollingLayout:1.2.4'
}

方式 2:

repositories {
    // ...
    jcenter()
}
dependencies {
    implementation 'com.jarvis.library.NestedTouchScrollingLayout:library:1.2.4'
}

Tip

star star star !!!!😊

LICENSE

This library is under the MIT license. check the LICENSE file for more detail.

Copyright (c) 2018 Jarvis

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].