Using Google Design Library how to hide FAB button on Scroll down?

If you’re using RecyclerView and you’re looking for something simple, you can try this: recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){ @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy){ if (dy > 0) fabAddNew.hide(); else if (dy < 0) fabAddNew.show(); } }); By replacing 0 with a constant, you can adjust the sensitivity of triggering, providing smoother experience

CoordinatorLayout using the ViewPager’s RecyclerView

Chris Banes has posted a sample on Github which shows exactly what you want to do. Here is the xml file that defines how one can indirectly attach a coordinator layout to the viewpager’s fragments. <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/main_content” android:layout_width=”match_parent” android:layout_height=”match_parent”> <android.support.design.widget.AppBarLayout android:id=”@+id/appbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:background=”?attr/colorPrimary” app:popupTheme=”@style/ThemeOverlay.AppCompat.Light” app:layout_scrollFlags=”scroll|enterAlways” /> <android.support.design.widget.TabLayout … Read more

How to reset the Toolbar position controlled by the CoordinatorLayout?

To reset the scroll state, just get the AppBarLayout.Behavior object CoordinatorLayout coordinator = (CoordinatorLayout) findViewById(R.id.coordinator); AppBarLayout appbar = (AppBarLayout) findViewById(R.id.appbar); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appbar.getLayoutParams(); AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior(); and call onNestedPreScroll method manually: int[] consumed = new int[2]; behavior.onNestedPreScroll(coordinator, appbar, null, 0, -1000, consumed); If you would like to reset smoothly with an … Read more

How to use setDuration() method in SnackBar (Android Design Support Library)

Based on the implementation of Snackbar and SnackbarManager, I can confirm Eugene H’s assessment: it’s a bug. From SnackbarManager: private void scheduleTimeoutLocked(SnackbarRecord r) { mHandler.removeCallbacksAndMessages(r); mHandler.sendMessageDelayed(Message.obtain(mHandler, MSG_TIMEOUT, r), r.duration == Snackbar.LENGTH_LONG ? LONG_DURATION_MS : SHORT_DURATION_MS); } So, any value that is not LENGTH_LONG results in a short-duration snackbar. I have filed an issue about it. … Read more

Android – footer scrolls off screen when used in CoordinatorLayout

I use a simplified version of Learn OpenGL ES’s solution — which improves on Noa’s solution. It works fine for my simple quick-return toolbar above a TabLayout with footer buttons in each tab’s ViewPager content. Just set the FixScrollingFooterBehavior as the layout_behavior on the View/ViewGroup you want to keep aligned at the bottom of the … Read more

How to disable scrolling of NestedScrollView&CollapsingToolbarLayout, for example when there is no more content below?

What can I do in order to make the scrolling stop when there is no more content to show at the bottom? Firstly, as I have commented below, the scrolling you said in your question is not of the NestedScrollView. It belongs to the CollapsingToolbarLayout. The NestedScrollView‘s scroll event only happens when CollapsingToolbarLayout fully collapsed, … Read more