Android LiquidSwipe Library

Overview

LiquidSwipe

Android LiquidSwipe Library

License: MIT API

Default Touch Interactive

LiquidSwipe is a viewpager library that can be used to make awesome onboarding designs. (Default Demo apk) (TouchInteractive Demo apk)

If you like this, you'll like ConcentricOnboarding as well.

Demo app

To run the demo project, clone the repository and run it via Android Studio.
(OR)
Download the latest demo apk from releases.

Usage

Set up the dependency

  1. Add the JitPack repository to your root build.gradle at the end of repositories:
allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
  1. Add the LiquidSwipe dependency in the build.gradle:
implementation 'com.github.Chrisvin:LiquidSwipe:1.3'

Use LiquidSwipeViewPager instead of the normal ViewPager

<androidx.constraintlayout.widget.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.jem.liquidswipe.LiquidSwipeViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Use a LiquidSwipeLayout as the base container in the fragment layouts

<?xml version="1.0" encoding="utf-8"?>
<com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".DummyFragment">

    <!--  Fill with your views, just like you would in a normal ConstraintLayout  -->

</com.jem.liquidswipe.layout.LiquidSwipeConstraintLayout>

<!--  Also supports LiquidSwipeFrameLayout & LiquidSwipeLinearLayout  -->

Note : Dokka generated documentation on LiquidSwipeLayouts

And you're done, easy-peasy. ^_^

Touch Interactive - Making the LiquidSwipe wave center Y value match the touch Y value

Rather than having the wave center Y value always be layout.height/2 , it would be more aesthetically pleasing for it to be the same as the touch Y value. The following code can be used to dynamically change the waveCenterY based on the touch position on the LiquidSwipeViewPager. (The reason this isn't done internally in the library is because the viewpager layouts don't get the touch events when said touch events are consumed directly by the viewpager)

  1. In the Activity/Fragment class containing the LiquidSwipeViewPager
// Create an array of LiquidSwipeCPP, one for each layout in the PagerAdapter
val liquidSwipeClipPathProviders = Array(titleArray.count()) {
    LiquidSwipeClipPathProvider()
}

// Pass the LiquidSwipeCPP array to the adapter
viewpager.adapter = CustomPagerAdapter(this, liquidSwipeClipPathProviders)
// Similar logic can also be applied for your custom FragmentPagerAdapter/FragmentStatePagerAdapter

// Listen to onTouch events on the viewpager and update the waveCenterY value of the LiquidSwipeCPPs
viewpager.setOnTouchListener { _, event ->
    val waveCenterY = event.y
    liquidSwipeClipPathProviders.map {
        it.waveCenterY = waveCenterY
    }
    false
}
  1. In the PagerAdapter
// Set the layout's clipPathProvider to the corresponding `LiquidSwipeClipPathProvider`
(layout as? LiquidSwipeLayout)?.clipPathProvider = liquidSwipeClipPathProviders[position]

The above code has been showcased in the demo app, feel free to look at it for reference.

Note: This is not a perfect solution, in fact some artifacts might occur due to the quick waveCenterY value jumps. But for now, this is the cleanest solution I can think of. Anyone else with a better solution is welcome to fork and submit a pull request. :)

Creating custom swipe animations

The concept for the ClipPathProvider in LiquidSwipe is the same as that in the EasyReveal library (If you haven't already, then you should really check it out, infact the first version of LiquidSwipe used EasyReveal as a dependency).

You can create your own swipe animation by extending the ClipPathProvider and implementing the getPath() method. getPath() provides the Path for a given percent value on the provided view. The path gotten from getPath() is then used to clip the view using canvas.clipPath(path, op) (The op value is provided by the ClipPathProvider as well). You can then set your custom ClipPathProvider to your layouts.

API Documentation

Documentation generated using Dokka : chrisvin.github.io/LiquidSwipe

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

Credits

  1. Cuberto's liquid-swipe for iOS - Source of inspiration
  2. Alvaro Fabre - Designer of the lottie animations in the demo app

License

MIT License

Copyright (c) 2019 Jem

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Crash

    Crash

    when i convert it in ontouchListener swipe and when i swipe more than 4-5 pages it gives this error java.lang.ArrayIndexOutOfBoundsException: length=5; index=5 at com.example.liquidswipedemo.CustomPagerAdapter.instantiateItem(CustomPagerAdapter.kt:27) at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010) at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1224) at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092) at androidx.viewpager.widget.ViewPager$3.run(ViewPager.java:273) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:977) at android.view.Choreographer.doCallbacks(Choreographer.java:785) at android.view.Choreographer.doFrame(Choreographer.java:714) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:963) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6819) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912)

    opened by UmairAhmed420 4
  • just a suggestion.... new idea

    just a suggestion.... new idea

    your library is awesome .... can you implement one more thing in this library? that is how about when we swipe it detects gesture from where of screen user is swiping so the liquid effects goes there or start from there not from a static position which is mentioned ios library

    opened by UmairAhmed420 2
  • Add support for ViewPager2

    Add support for ViewPager2

    Current LiquidSwipeViewPager is extended from androidx.viewpager.widget.ViewPager.

    Create LiquidSwipeViewPager which would extend androidx.viewpager2.widget.ViewPager2.

    enhancement 
    opened by Chrisvin 1
  • Swipe arrow icon color conflicts with the color of the next background

    Swipe arrow icon color conflicts with the color of the next background

    The icon that is used swipe to the next page has the same color as the next background and therefore appears invisible. How do i customize the color of the Icon?

    opened by Joealtidore1 0
  • Touch Interaction not working in java code

    Touch Interaction not working in java code

    I have made the app in java so I am having problem regarding touch interaction part because some function don't match in kotlin and java. Please provide code for java too.

    opened by CoderHermione 2
  • How to animate from bottom to top

    How to animate from bottom to top

    I want to animate the layout with similar animation but from bottom to top. How can I achieve this animation.

    Sorry for posting this question in the issue.

    It will be very helpful if you guide me to solve the problem.

    enhancement good first issue question 
    opened by Naveen3921 1
Releases(1.3)
Owner
Chrisvin Jem
Programmer
Chrisvin Jem
Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API

What is Postman? Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API Usage P

Cafer Mert Ceyhan 129 Dec 24, 2022
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

1. Add dependency dependencies { implementation 'com.hbb20:android-country-picker:X.Y.Z' } For latest version, 2. Decide your use-case

Harsh B. Bhakta 65 Dec 6, 2022
Android library for swipable gestures

Swipper Android Library for custom views to control brightness , volume and seek through swipable gestures . These views could easily replace the conv

Mobile Development Group 105 Dec 30, 2022
Android Library that lights items for tutorials or walk-throughs etc...

Spotlight Gradle dependencies { implementation 'com.github.takusemba:spotlight:x.x.x' } Usage val spotlight = Spotlight.Builder(this) .setTarg

TakuSemba 3.4k Jan 4, 2023
[] An Android library which allows developers to easily add animations to ListView items

DEPRECATED ListViewAnimations is deprecated in favor of new RecyclerView solutions. No new development will be taking place, but the existing versions

Niek Haarman 5.6k Dec 30, 2022
Android Rubber Picker Library

RubberPicker RubberPicker library contains the RubberSeekBar and RubberRangePicker, inspired by Cuberto's rubber-range-picker. Getting started Setting

Chrisvin Jem 547 Jan 5, 2023
EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the Etsy app.

EtsyBlur EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the past Etsy app. Try out the sa

Manabu S. 755 Dec 29, 2022
[] Android library for using the Honeycomb animation API on all versions of the platform back to 1.0!

DEPRECATED NineOldAndroids is deprecated. No new development will be taking place. Existing versions will (of course) continue to function. New applic

Jake Wharton 4.5k Jan 9, 2023
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

Stfalcon LLC 3.6k Jan 5, 2023
An Android library which provides simple Item animations to RecyclerView items

RecyclerViewItemAnimators Library Travis master: This repo provides: Appearance animations Simple animators for the item views Quick start You can now

Gabriele Mariotti 3.1k Dec 16, 2022
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

Ian Thomas 2.5k Dec 29, 2022
Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa

FabulousFilter Show some ❤️ and star the repo to support the project This library is the implementation of filter-concept posted on MaterialUp.com. It

Krupen Ghetiya 2.6k Jan 3, 2023
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Road Runner is a library for android which allow you to make your own loading animation using a SVG image

Road Runner Road Runner is a library for android which allow you to make your own loading animation using a SVG image Sample video View in Youtube Dem

Adrián Lomas 1.2k Nov 18, 2022
FPSAnimator is very easy animation library for Android TextureView and SurfaceView.

FPSAnimator A simple but powerful Tween / SpriteSheet / ParabolicMotion / animation library for Android TextureView and SurfaceView. Features The cont

Masayuki Suda 756 Dec 30, 2022
Android library for material scrolling techniques.

material-scrolling Android library for material scrolling techniques. Features Easily implement material scrolling techniques with RecyclerView. Custo

Satoru Fujiwara 601 Nov 29, 2022
Android library to display a few images in one ImageView like avatar of group chat. Made by Stfalcon

MultiImageView Library for display a few images in one MultiImageView like avatar of group chat Who we are Need iOS and Android apps, MVP development

Stfalcon LLC 468 Dec 9, 2022
Android library to create complex multi-state animations.

MultiStateAnimation Android library to create complex multi-state animations. Overview A class that allows for complex multi-state animations using An

Keepsafe 405 Nov 11, 2022
Fast marker clustering library for Google Maps Android API.

Google Maps Clustering for Android A fast marker clustering library for Google Maps Android API. Motivation Why not use Google Maps Android API Utilit

Sharewire 294 Dec 5, 2022