How to push up an existing view when snackbar is displayed?
After testing several solutions, I came across one xml layout that works.
The main difference between what I had tried before and the below is that the coordinatorlayout
height is "match_parent
" which means it overlays the views below it but because the coordinatorlayout
is transparent, you don't see it and when the snackbar
pushes up from the bottom, it will now have enough room to push the textview
above the snackbar
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click Here!"
android:textAllCaps="true"
android:textStyle="bold"
android:background="@color/colorAccent"
android:id="@+id/click_here"
android:textSize="22sp"
android:layout_marginBottom="12dp"
android:gravity="center_horizontal"
android:paddingTop="24dp"
android:paddingLeft="24dp"
android:paddingRight="24dp" />
<ImageButton
android:id="@+id/btnComments"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_below="@+id/click_here"
android:layout_centerHorizontal="true"
android:background="@drawable/shadow_bg"
android:src="@mipmap/ic_launcher" />
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|bottom">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/next"
android:text="Next"
android:background="@color/colorAccent"
android:clickable="true"
android:gravity="center_horizontal"
android:padding="16dp"
android:textAllCaps="true"
android:textStyle="bold"
android:layout_gravity="center_horizontal|bottom"
app:layout_behavior="fabmotiontest.com.fabtest.FloatingActionButtonBehavior" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>