0

I have a simple NavGraph and I'm trying to add some animations. The animations work when using

findNavController().navigate(action)

but not with the bottomnavigation view.

I have tried with different variations of animations in the actions but none of them work with the bottomnavigation controller

I set it up here

 bottomNavigationView.setupWithNavController(navController)

        navController.addOnDestinationChangedListener { controller, destination, arguments ->
            when (destination.id) {
                R.id.mapFragment -> showBottomSheet(true)
                R.id.settingsFragment -> {
                    showBottomNavigation(false)
                    showBottomSheet(false)
                }
                else -> showBottomSheet(false)
            }
        }

Here is the bottomnavigation XML

<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/job_nav_graph"
    app:startDestination="@id/jobsListFragment">

        <fragment
            android:id="@+id/jobsListFragment"
            android:name="com.plcoding.posterpalfeature.ui.fragments.JobsListFragment"
            android:label="JobsListFragment"
            tools:layout="@layout/fragment_job_list">
            <action
                android:id="@+id/action_jobsListFragment_to_mapFragment"
                app:destination="@id/mapFragment"
                app:enterAnim="@anim/slide_in_left"
                app:exitAnim="@anim/slide_out_right"
                app:popEnterAnim="@anim/slide_in_left"
                app:popExitAnim="@anim/slide_out_right" />
            <action
                android:id="@+id/action_jobsListFragment_to_jobDetailFragment"
                app:destination="@id/jobDetailFragment"
                app:enterAnim="@anim/slide_in_right"
                app:exitAnim="@anim/slide_out_left"
                app:popEnterAnim="@anim/slide_in_right"
                app:popExitAnim="@anim/slide_out_left"
                app:popUpTo="@id/jobsListFragment"
                app:popUpToInclusive="true" />
            <action
                android:id="@+id/action_jobsListFragment_to_settings_graph"
                app:destination="@id/settings_graph" />
        </fragment>
        <fragment
            android:id="@+id/jobDetailFragment"
            android:name="com.plcoding.posterpalfeature.ui.fragments.JobDetailFragment"
            android:label="JobDetailFragment"
            tools:layout="@layout/fragment_job_detail">
            <argument
                android:name="jobId"
                android:defaultValue="1"
                app:argType="integer" />
        </fragment>
        <fragment
            android:id="@+id/mapFragment"
            android:name="com.plcoding.posterpalfeature.ui.fragments.MapFragment"
            android:label="MapFragment"
            tools:layout="@layout/fragment_map_detail" />

        <include app:graph="@navigation/settings_graph"/>

</navigation>

slide in left

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:duration="400"
        android:fromXDelta="-100%"
        android:fromYDelta="0%"
        android:toXDelta="0%"
        android:toYDelta="0%" />
</set>

slide in right

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:duration="400"
        android:fromXDelta="100%"
        android:fromYDelta="0%"
        android:toXDelta="0%"
        android:toYDelta="0%" />
</set>

slide out left

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:duration="400"
        android:fromXDelta="0%"
        android:fromYDelta="0%"
        android:toXDelta="-100%"
        android:toYDelta="0%" />
</set>

slide out right

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:duration="400"
        android:fromXDelta="0%"
        android:fromYDelta="0%"
        android:toXDelta="100%"
        android:toYDelta="0%" />
</set>

user1743524
  • 655
  • 1
  • 7
  • 14

0 Answers0