Giter VIP home page Giter VIP logo

dragsloplayout's Introduction

DragSlopLayout

Apache 2.0 License

一个辅助开发的UI库,适用于某些特殊场景,如固定范围拖拽、动画、模糊效果等。

Screenshot

Drag模式,可以和 ViewPager 联动

Drag

Animate模式,同样可以和 ViewPager 联动(自定义动画无联动效果)

Animate

Blur模糊效果,包括局部模糊和全图模糊

Blur

外部拖拽,在屏幕上垂直滑动就可对视图进行拖拽,能够设置主视图滑动折叠

Blur

Gradle

库依赖

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

因为模糊库比较大,如果你需要使用模糊效果则依赖的版本{lastest-version}后面加上'-blur',不需要则不用加

compile 'com.github.Rukey7:DragSlopLayout:{lastest-version}-blur'

使用模糊库需要设置对应的配置

android {
    defaultConfig {
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
    }
}

Usage

属性

name format description
mode enum drag、animate或者drag_outside, 默认为 drag
fix_height dimension drag模式收缩的高度, 默认为 0
max_height dimension drag模式展开的高度,默认为布局高度的 2/3
collapse_parallax float 折叠系数,效果同 CollapsingToolbarLayout,默认为 1

布局

<com.dl7.drag.DragSlopLayout
	android:id="@+id/drag_layout"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:background="@android:color/black"
	app:fix_height="80dp"
	app:mode="drag">
		<!-- Content View -->
		<android.support.v4.view.ViewPager
		android:id="@+id/vp_photo"
		android:layout_width="match_parent"
		android:layout_height="match_parent"/>
		
		<!-- Drag View -->
		<LinearLayout
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:orientation="vertical">
		// ......
	</LinearLayout>
	// ......
</com.dl7.drag.DragSlopLayout>

如果 Content View 为 ViewPager,通过以下方法来实现联动效果:

    mDragLayout.interactWithViewPager(true);
	// 下面新增的方法会更适用,替换上面旧的方法
	mDragLayout.attachViewPager(ViewPager);
	mDragLayout.detachViewPager();
	

如果 Drag View 包含 ScrollView 或则 NestedScrollView,通过以下方法来实现平滑滚动:

    mDragLayout.setAttachScrollView(mSvView);

Content View 的模糊效果,这功能是通过模糊预处理再来动态加载的,所以对于 Content View 为 ViewPager 的界面不适用,主要用来模糊固定的背景界面

    mDragLayout.setEnableBlur(true);	// 开启模糊
    mDragLayout.setBlurFull(true);	// 设置全背景模糊,默认为局部模糊
    mDragLayout.updateBlurView();	// 更新模糊背景

控制 Drag View 的进入和退出

    mDragLayout.scrollInScreen(int duration);	// Drag 模式
    mDragLayout.scrollOutScreen(int duration);	// Drag 模式

    mDragLayout.startInAnim();	// Animate 模式
    mDragLayout.startOutAnim();	// Animate 模式
    mDsLayout.setAnimatorMode(DragSlopLayout.FLIP_Y);	// 设置动画模式

设置拖拽监听

    mDragLayout.setDragPositionListener(new DragSlopLayout.OnDragPositionListener() {
            @Override
            public void onDragPosition(int visibleHeight, float percent, boolean isUp) {
                // TODO
            }
        });

Thanks

License

Copyright 2016 Rukey7

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

dragsloplayout's People

Contributors

rukey7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dragsloplayout's Issues

滑动事件问题

<com.dl7.drag.DragSlopLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dsl_drag"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
app:mode="drag_outside">

<!-- Content View -->
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

   <!--..............-->

</LinearLayout>


<!-- Drag View -->
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center_vertical"
        android:text="title" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_member"
        android:layout_width="match_parent"
        android:layout_height="600dp"
        android:background="@color/white2" />

</LinearLayout>

</com.dl7.drag.DragSlopLayout>

如果RecyclerView 数据量多的时候,展开dragview后RecyclerView 滑动事件失效,数据只展示一部分,如何解决dragview的滑动和RecyclerView滑动,当RecyclerView滑到顶部在触发dragview下滑 ,当dargview上滑到最大位置在触发RecyclerView上滑。

一个小问题

比如我再layout中设置了fix_height是200dp。但是viewpage中一个item的dragView大小不足200dp。这时候会出现其他的item的fix_height都变成了最小的那个了

question

hello , please can you help me in two things : firstly: the implementation of te library not work on te gradle
Could not find com.github.Rukey7:DragSlopLayout:{lastest-version}-blur
second please can you explain to me more how you are doing the collapse text layout flexible with the view and how you made the height changin by the touch of user , look this photo 👍 https://ibb.co/cjUVSo , wish to answer me soon regards

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.