I have a BottomNavigationView inside a CoordinatorLayout with and I want to move snackbar above bottomNavigationView but snackbar visible behind bottomNavigationView
My navigationView when scroll show/hide when hide snack bar visible
activity_main.xml
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_coordinatorLayout"
tools:context=".MainActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="@font/open_sans_bold"
android:text="@string/app_name"
android:textColor="#FFF"
android:textSize="20sp"
tools:layout_editor_absoluteX="143dp"
tools:layout_editor_absoluteY="14dp" />
</androidx.appcompat.widget.Toolbar>
<androidx.viewpager.widget.ViewPager
android:id="@+id/main_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="?actionBarSize"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:labelVisibilityMode="auto"
android:layout_gravity="bottom"
app:itemTextColor="@color/nav_color"
app:itemIconTint="@color/nav_color"
app:menu="@menu/bottom_navigation_menu" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
fragment.java
Snackbar.make(getActivity().findViewById(R.id.main_coordinatorLayout),"Message",Snackbar.LENGTH_INDEFINITE).show();
Sorry for my bad English
In the google material component library you can use Snackbar
with anchor method like below:
Snackbar snackbar = Snackbar.make(view,"text",Snackbar.LENGTH_SHORT);
snackbar.setAnchorView(bottomNavigationView);
snackbar.show();