0

I have implemented a BottomNavigationView and I would like to hide the menu on scroll.

In the MainActivity

private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
        when (item.itemId) {
            R.id.navigation_home -> {
                switchFragment(ActivitiesFragment.newInstance(), ActivitiesFragment.TAG)
                return@OnNavigationItemSelectedListener true
            }
            R.id.navigation_dashboard -> {
                switchFragment(FavoritesFragment.newInstance(), FavoritesFragment.TAG)
                return@OnNavigationItemSelectedListener true
            }
            R.id.navigation_notifications -> {
                switchFragment(MapFragment.newInstance(), MapFragment.TAG)
                return@OnNavigationItemSelectedListener true
            }
        }
        false
    }

My xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/navigation"
        android:layout_below="@+id/main"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>

So far I have found how to implement the the functionality using java but I would like to know what would be the right process to implement this kind of animation.

Note: Android support version 27.1.1

gon250
  • 3,405
  • 6
  • 44
  • 75
  • Possible duplicate of [Hide/Show bottomNavigationView on Scroll](https://stackoverflow.com/questions/44777869/hide-show-bottomnavigationview-on-scroll) – JediBurrell Sep 19 '18 at 21:33

1 Answers1

0

Jetbrains IDE can convert Java to Kotlin automatically when you paste the code there. Try to use Java code or try this Hide/Show bottomNavigationView on Scroll

Angelina
  • 1,473
  • 2
  • 16
  • 34