How to disable scrolling of AppBarLayout in CoordinatorLayout?

I’m not sure I got it, but I think you are looking for a DragCallback. The DragCallback interface allows to choose whether the sibling scrolling view should be controlled by scrolls onto the AppBarLayout. You can define one by calling: CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams(); AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior(); behavior.setDragCallback(new AppBarLayout.Behavior.DragCallback() { @Override public … Read more

Android – the item inside RecyclerView can’t be clicked after scroll

Found a way to force the scroll state to be idle. Waiting for google to fix this bug. @Override public boolean onInterceptTouchEvent(MotionEvent event) { boolean requestCancelDisallowInterceptTouchEvent = getScrollState() == SCROLL_STATE_SETTLING; boolean consumed = super.onInterceptTouchEvent(event); final int action = event.getActionMasked(); switch (action) { case MotionEvent.ACTION_DOWN: if( requestCancelDisallowInterceptTouchEvent ){ getParent().requestDisallowInterceptTouchEvent(false); // only if it touched the top … Read more

CoordinatorLayout inside another CoordinatorLayout

I know it’s an old question. But I searched a long time to include an CoordinatorLayout in a fragment, which is in another CoordinatorLayout. I modified the answer of dev.bmax a little bit to call both coordinator layouts and call the attached behaviors of both layouts. So here is my solution. @SuppressWarnings(“unused”) public class NestedCoordinatorLayout … Read more

NestedScrollView’s smoothScrollTo() behaves weird

Looks like there is a bug when programmatically scrolling NestedScrollView within CoordinatorLayout. This solved my problem: private void scrollToView(final View view) { mScroller.scrollBy(0, 1); mScroller.smoothScrollTo(0, view.getTop()); } or for better control: private void scrollToView(final View view) { mScroller.scrollBy(0, 1); ObjectAnimator.ofInt(mScroller, “scrollY”, view.getTop()).setDuration(700).start(); }

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

Android Layout: Horizontal Recyclerview inside a Vertical Recyclerview inside a Viewpager with Scroll Behaviors

Tested solution: All you need is to call mInnerRecycler.setNestedScrollingEnabled(false); on your inner RecyclerViews Explanation: RecyclerView has support for nested scrolling introduced in API 21 through implementing the NestedScrollingChild interface. This is a valuable feature when you have a scrolling view inside another one that scrolls in the same direction and you want to scroll the … Read more

Theme Error – how to fix?

This is a bug in 28.0.0 and the only fix(workaround) is adding this to your Build.gradle: configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == “com.android.support”) { if (!requested.name.startsWith(“multidex”)) { details.useVersion “27.1.1” } } } } Which somehow, this bypasses the issue and uses 27 support library for that. Otherwise, … Read more

Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

It worked when I downgrade the support appcompat gradle dependency, like follwing : implementation ‘com.android.support:appcompat-v7:27.0.2’ previously it was implementation ‘com.android.support:appcompat-v7:27.1.0’ OR Also this can be fixed by just adding support design dependency of version 27.1.0 or above to your app level build.gradle as following : implementation ‘com.android.support:design:27.1.0’

Add views below toolbar in CoordinatorLayout

Take the attribute app:layout_behavior=”@string/appbar_scrolling_view_behavior” off the RecyclerView and put it on the FrameLayout that you are trying to show under the Toolbar. I’ve found that one important thing the scrolling view behavior does is to layout the component below the toolbar. Because the FrameLayout has a descendant that will scroll (RecyclerView), the CoordinatorLayout will get … Read more

Android – footer scrolls off screen when used in CoordinatorLayout

I use a simplified version of Learn OpenGL ES’s solution (https://stackoverflow.com/a/33396965/778951) — which improves on Noa’s solution (https://stackoverflow.com/a/31140112/1317564). 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 … Read more