PullDownLayout

Additional

Language
Kotlin
Version
1.0.0 (Oct 5, 2018)
Created
Oct 5, 2018
Updated
Oct 5, 2018
Owner
Deepan (tizisdeepan)
Contributor
Deepan (tizisdeepan)
1
Activity
Badge
Generate
Download
Source code

Advertising

PullDownLayout

What is Pull Down Layout?

PullDownLayout is a small library that allows you to implement a view that can be dragged down your layout. PullDownLayout can also be used to implement Pull-To-Dismiss feature for your activities and fragments.

Implementation

[1] In your app module gradle file

dependencies {
    implementation 'com.github.tizisdeepan:pulldownlayout:1.0.0'
}

[2] In your project level gradle file

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

[3] Use PullBackLayout in your layout.xml

<com.layout.pulldown.PullDownLayout
        android:id="@+id/pullDown"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
  <!--Your Views-->
</com.layout.pulldown.PullDownLayout>

[4] Set Callback for PullBackLayout in your Activity or Fragment

class FragmentClass: Fragment(), PullDownLayout.Callback {
    override fun onPullStart() {
    }

    override fun onPull(progress: Float) {
    }

    override fun onPullCancel() {
    }

    override fun onPullComplete() {
        (ctx as MainActivity).onBackPressed()
    }
    
    ...
    
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        pullDown.setCallback(this)
    }
}

Note: Check out sample project for cool pull down transitions.

And that's it! You have now successfully implemented a cool PullDownLayout for your android project!