Home > Mobile >  How can I move from one screen to another with swipe up gestures?
How can I move from one screen to another with swipe up gestures?

Time:10-25

I am building an application right now and I’m trying to add some animation and movement to my application. I’ve researched multiple times but couldn’t find the answer to my question. I’m starting at the welcome screen and I want to user to swipe up to move to the sign up screen.

CodePudding user response:

using pager

implementation "com.google.accompanist:accompanist-pager:0.25.0"

CodePudding user response:

You could use a ViewPager. With the first item in the ViewPager being your welcome page and the second being your login page. The ViewPager would take care of the swipes and animations itself and probably simplify things for you.

Simple example for ViewPager

You could alternatively create a GestureDetector from your welcome page and listen for a swipe up to open your login page. Then you could open your login page using either an intent or a transaction with a FragmentManager and by defining an animation for the transition.

Simple example for GestureDetector

There's many ways of accomplishing this depending on how you want your app to be structured.

  • Related