Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java for Android
  • Android Studio
  • Android Kotlin
  • Kotlin
  • Flutter
  • Dart
  • Android Project
  • Android Interview
Open In App
Next Article:
BottomNavigationView in Android
Next article icon

How to Hide/Show BottomNavigationView on Scroll in Android?

Last Updated : 08 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

BottomNavigationView is the best option for navigation in Android. It makes life easier for a user to switch between multiple activities and fragments. It’s really a pain in the butt to use an Android app without having proper navigation. At GFG, we have already shared an article with you on BottomNavigationView. If you are new or don’t know what is BottomNavigationView or want to implement it in your app then please refer to BottomNavigationView in Android.

We all are using Android apps in our daily lives. If you will observe carefully, you will find that an application with a better user interface gets a heart from the user. He will love using that application and will come again and again. For creating better and professional user interfaces you have to take care of these small things. When a BottomNavigationView will show and hide on scrolling it will look much more professional and practical. You have also seen in LinkedIn, that how it’s BottomNavigationView shows and hides on scrolling. Do you also not want to implement it in the BottomNavigationView of your own app. In this article, we are going to discuss how to implement this type of behaviour in our Android app. After going through this article, and understanding the logic you will be able to use it everywhere.

Step-by-Step Implementation

A sample GIF is given below to get an idea about what we are going to do in this article. This is a language-independent tutorial, the steps will be the same for Java and Kotlin.

https://media.geeksforgeeks.org/wp-content/uploads/20240801005130/HideShowBottomNavigationViewonScrollinAndroid.mp4

Step 1: Open an existing project which has BottomNavigationView and you want to work on it. If you haven’t created it yet then you can always refer to this BottomNavigationView in Android and create it. You may also clone this GitHub project for implementation. And we have used this project as an example in this article.

Note: Please refer to this article to clone Android Project from GitHub in Android Studio.

Step 2: Then navigate to the Layout resource File on which you have used the BottomNavigationView. For Example, we have used it in the activity_home.xml file with RecyclerView.

Step 3: Now make sure that the parent layout for that layout resource file is CordinatorLayout because this behavior will not work in any other type of layout. It will only work in CordinatorLayout.

Note: CordinatorLayout is an advanced layout in android, It has much more interesting functionalities. While you will be dealing with the complex UI’s in android, then you can do it more efficiently in CordinatorLayout. You can read more about the CordinatorLayout from here.

Step 4: Now, In BottomNavigationView add an attribute like this. 

XML
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"/>.  

Step 5: Try running your application on an emulator or a physical device. In this sample project, we have used a RecyclerView with BottomNavigationView. You can do the same with ScrollView or any other object in android.

Output UI:

https://media.geeksforgeeks.org/wp-content/uploads/20201222104946/output_video.mp4


Next Article
BottomNavigationView in Android
author
encrypter09
Improve
Article Tags :
  • Android
  • Android Projects

Similar Reads

  • How to Save Fragment States with BottomNavigationView in Android?
    In Android applications, Activities and Fragments are from the foundation of the UI layer. It is now standard practice to load the UI with multiple fragments. For example, Instagram, Twitter, and a slew of other well-known apps. Imagine browsing some tweets in the Twitter app's HomeFragment, navigat
    4 min read
  • BottomNavigationView in Android
    BottomNavigationView makes it easy for users to explore and switch between top-level views with a single tap. There should be a minimum of 3 top-level views and a maximum of 5. If Destinations are more than 5 then use the Navigation Drawer. When the user taps on the icon it will change the top-level
    5 min read
  • How to Detect End of ScrollView in Android?
    In Android, a ScrollView is a view that lets the user scroll up and down to visit elements declared inside it. ScrollView is most commonly used to display TextView that contains a large amount of text which does not fit on a single instance of a screen. Users can scroll down and up to read complete
    3 min read
  • How to Disable GridView Scrolling in Android?
    A GridView is a ViewGroup that can display data from a list of objects or databases in a grid-like structure consisting of rows and columns. Grid view requires an adapter to fetch data from the resources. This view can be scrolled both horizontally and vertically. The scrolling ability of the GridVi
    4 min read
  • How to Add Fade and Shrink Animation in RecyclerView in Android?
    In this article, we are going to show the fade and shrink animation in RecyclerView. When we move downward then the item at the top will be fading out and then it will shrink. In the output, we can see how it is happening. We will be implementing Java/Kotlin programming language. Step by Step Implem
    15+ min read
  • Curve Navigation Drawer in Android using ArcNavigationView
    The Navigation Drawer is a layout that can be seen in certain applications, that consists of some other activity shortcuts (Intents). This drawer generally can be seen at the left edge of the screen, which is by default. A Button to access the Navigation Drawer is by default provided at the action b
    2 min read
  • Scroll ImageView in Android
    In this article, we are going to implement a very important feature related to the ImageView. The image will keep on scrolling horizontally by itself. When we click on the image then it will stop scrolling and when we again click it will again keep scrolling. We can use this feature to show animatio
    3 min read
  • How to Keep the Device Screen On in Android?
    In Android it's seen that screen timeout will be set for 30 seconds or it is set by the user manually in system settings, to avoid battery drain. But there are cases where applications like stopwatch, document reader applications, games, etc, need the screen to be always awake. In this article its b
    4 min read
  • How to Show and Hide a View with a Slide Up and Down Animation in Android?
    View in android is an area of the screen which is responsible for drawing and event handling. The layout is a collection of views. It consists of some content like images, text, a button, or anything that an android app can display. In this article, we will take a look at how to show and hide a view
    3 min read
  • How to Disable Back Press Button in Android?
    Physical keys on Android let users lock the phone, switch off the device, control volume, go back, go home and display background applications. Between all the keys, the back button is used the most in applications for navigating between activities. However, if the navigation stage reaches the start
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences