How to make a custom snackbar (support API 14) be above of the window insets?

Viewed 80

I have this layout

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/snackbar_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="top|center" />

  <com.google.android.material.button.MaterialButton
      android:id="@+id/show_snackbar_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:text="@string/show_snackbar"
      android:theme="@style/Theme.GoogleMaterial.DayNight.Bridge" />
</FrameLayout>

I have a customized class:

public final class MySnackbar<AccountT>
    extends BaseTransientBottomBar<MySnackbar<myT>> {

with

super(findTopMostFrameLayout(parent), content, new MySnackbarAnimation(content));

for:

 @VisibleForTesting
  protected static ViewGroup findTopMostFrameLayout(View view) {
    FrameLayout fallback = null;
    while (view != null) {
      if (view instanceof FrameLayout) {
        fallback = (FrameLayout) view;
      }
      final ViewParent parent = view.getParent();
      view = parent instanceof View ? (View) parent : null;
    }
    if (fallback != null) {
      return fallback;
    }
    throw new IllegalStateException(
        "Snackbar requires a frameLayout in the view hierarchy tree");
  }

when calling "show()", it shows an android snackbar with customized layout.

enter image description here

When I show a my_snackbar it's seen below the bottom navigation bar (z axis).

How can I make it above of the navigation bar (z-axis and y-axis)?

I can make sure the layout has a frame layout which is not the root view. So I thought my layout would be OK. no?

I saw this post, but I need to support API 14 and onApplyWindowInsets() is from Lollipop.

0 Answers
Related