Using the 23.3.0 version of the support libraries and testing on Android M. And having issues with a FAB repositioning itself after a Snackbar is shown.
The fab correctly moves up when a Snackbar is shown, however it does not move down when the Snackbar dismisses itself.
Code:
Snackbar.make(coordinatorLayout, R.string.msg_add_team, Snackbar.LENGTH_LONG).show();
Also tried to use the callback functionality of the Snackbar to force the position back on dismiss, this breaks subsequent displays of the Snackbar as it will no longer move the fab out of the way.
Code for callback:
@Override
public void onDismissed(Snackbar snackbar, int event) {
super.onDismissed(snackbar, event);
newGameFab.setTranslationY(0);
}
Layout:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/upcoming_game_list"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/new_game"
android:layout_width="56dp"
android:layout_height="56dp"
android:src="@drawable/ic_add_white_24dp"
android:layout_gravity="bottom|end"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_marginBottom="@dimen/fab_margin_bottom"
android:layout_marginRight="@dimen/fab_margin_right"
app:borderWidth="0dp"
app:backgroundTint="@color/accent"/>
wrap your View containing floating action button with a CoordinatorLayout
like this:
<android.support.design.widget.CoordinatorLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/coordinatorLayout">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/upcoming_game_list"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/new_game"
android:layout_width="56dp"
android:layout_height="56dp"
android:src="@drawable/ic_add_white_24dp"
android:layout_gravity="bottom|end"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
android:layout_marginBottom="@dimen/fab_margin_bottom"
android:layout_marginRight="@dimen/fab_margin_right"
app:borderWidth="0dp"
app:backgroundTint="@color/accent"/>
</android.support.design.widget.CoordinatorLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.