14/11/2026

Fabrikant Tech

Tech Specialists

The Android Arsenal – Navigation

Fragula is a swipe-to-dismiss extension for navigation component library for Android.
It is an adaptation of an earlier version created by @shikleev and now maintained in this repository.


  1. Gradle Dependency
  2. The Basics
  3. More Options
    1. Destination Arguments
    2. Multiple BackStacks
    3. Swipe Direction
  4. Page Transitions
  5. Theming

Gradle Dependency

Add this to your module’s build.gradle file:

The fragula-core module contains everything you need to get started with the library. It contains all core and normal-use functionality.


The Basics

First, you need to replace NavHostFragment with FragulaNavHostFragment in your layout:

Second, you need to replace your <fragment> destinations in graph with <swipeable> as shown below:

Finally, you need to set opaque background and layout direction flag to your fragment’s root layout to avoid any issues with swipe animation.

Now if you open the app you’ll see that you can swipe fragments like in Telegram, Slack and many other messaging apps.


More Options

Destination Arguments

In general, you should work with Fragula as if you would work with normal fragments. You should strongly prefer passing only the minimal amount of data between destinations, as the total space for all saved states is limited on Android.

First, add an argument to the destination:

Second, create a Bundle object and pass it to the destination using navigate() as shown below:

Finally, in your receiving destination’s code, use the getArguments() method to retrieve the Bundle and use its contents:

It’s strongly recommended to use Safe Args plugin for navigating and passing data, because it ensures type-safety.

Multiple BackStacks

Currently multiple backstacks is not supported, which means you can’t safely use extensions such as BottomNavigationView.setupWithNavController(...) without losing your current backstack.

Swipe Direction

If you want to change the direction of swipe gesture, you can do that by setting app:swipeDirection="..." manually in your navigation container. This example below sets up vertical swipe direction.

You can use either left_to_right (default) or right_to_left for horizontal direction. For vertical direction you can use only top_to_bottom, you can’t use bottom_to_top because it’s not supported due to internal ViewPager2 restrictions.


Page Transitions

You may want to know when the scrolling offset changes to make smooth transitions inside your fragment view. To start listening scroll events you need to retrieve SwipeController and set OnSwipeListener as shown below:

Note: Currently shared element transitions between destinations is not supported in any form.

Remember: you must remove the listener when the fragment view is destroyed.


Theming

In most of the cases there is no need to change any values, but if you wish to override these, there are attributes provided: