Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android hide and show bottom navigation

public class BottomNavigationViewBehavior extends CoordinatorLayout.Behavior<BottomNavigationView> {

private int height;

@Override
public boolean onLayoutChild(CoordinatorLayout parent, BottomNavigationView child, int layoutDirection) {
    height = child.getHeight();
    return super.onLayoutChild(parent, child, layoutDirection);
}

@Override
public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
                               BottomNavigationView child, @NonNull 
                               View directTargetChild, @NonNull View target,
                               int axes, int type)
{
    return axes == ViewCompat.SCROLL_AXIS_VERTICAL;
}

@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull BottomNavigationView child,
           @NonNull View target, int dxConsumed, int dyConsumed,
           int dxUnconsumed, int dyUnconsumed, 
            @ViewCompat.NestedScrollType int type)
{
   if (dyConsumed > 0) {
       slideDown(child);
   } else if (dyConsumed < 0) {
       slideUp(child);
   }
}

private void slideUp(BottomNavigationView child) {
    child.clearAnimation();
    child.animate().translationY(0).setDuration(200);
}

private void slideDown(BottomNavigationView child) {
    child.clearAnimation();
    child.animate().translationY(height).setDuration(200);
}
Comment

prevent bottom navigation bar from hiding text android

<com.google.android.material.bottomnavigation.BottomNavigationView
    ...
    app:labelVisibilityMode="labeled"/>
    
    <--shows the label of each item-->
Comment

PREVIOUS NEXT
Code Example
Java :: java draw image 
Java :: loop and save letters in a string java 
Java :: Java Iterating through LinkedList 
Java :: recursion java fibonacci 
Java :: run jar file with different jre 
Java :: can we serialize class in java 
Java :: array buffer 
Java :: array methods in java 
Java :: interface declaration in java 
Java :: java put() method 
Java :: java "-" 
Java :: for loop in java 
Java :: deep content 
Java :: How to send saved CSV file via email 
Java :: how to choose an element in a array list Java 
Java :: receive an int from terminal java 
Java :: Java Custom Annotations 
Java :: java modulus opperation 
Java :: Java try Keyword 
Java :: zoomin pdf in android studio 
Java :: close current file android studio shortct 
Java :: java split not working on comma 
Java :: trémaux’ methode 
Java :: action listener for button to close window java 
Java :: java nom de la methode actuel 
Java :: acceder a elementos de list java 
Java :: how to select multiple non-consecutive words on mac 
Java :: localdatetimw java input 
Java :: java random 8 digit number 
Java :: get whatsapp group id flutter 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =