CoordinatorLayout + AppBarLayout + NavigationDrawer

Your CoordinatorLayout is wrapping your DrawerLayout and NavigationView, which means the Coordinator is in control of how everything is laid out. You need to nest the Coordinator inside the drawer, like so: <android.support.v4.widget.DrawerLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/drawer_layout” android:layout_width=”match_parent” android:layout_height=”match_parent” android:clickable=”true” android:focusableInTouchMode=”true”> <android.support.design.widget.CoordinatorLayout xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/overview_coordinator_layout” android:layout_width=”match_parent” android:layout_height=”match_parent”> <android.support.design.widget.AppBarLayout 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/colorPrimaryDark” app:layout_scrollFlags=”enterAlways|scroll” /> … 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

How to set app:layout_scrollFlags for Toolbar programmatically

I’d strongly recommend against changing the scrolling flags based on what tab is selected – having the Toolbar automatically return (and the content move down) when scrolling to a non-recyclerview tab can be very jarring and probably not an interaction pattern you want (exasperated if your two RecyclerView tabs are next to one another). However, … Read more

Toolbar in AppBarLayout is scrollable although RecyclerView has not enough content to scroll

Edit 2: Turns out the only way to ensure Toolbar is not scrollable when RecyclerView is not scrollable is to set setScrollFlags programmatically which requires to check if RecyclerView’s is scrollable. This check has to be done every time adapter is modified. Interface to communicate with the Activity: public interface LayoutController { void enableScroll(); void … Read more

What is CoordinatorLayout?

What is a CoordinatorLayout? Don’t let the fancy name fool you, it is nothing more than a FrameLayout on steroids To best understand what a CoordinatorLayout is/does, you must first of all understand/bear in mind what it means to Coordinate. If you Google the word Coordinate This is what you get: I think these definitions … Read more

How to mimic Google Maps’ bottom-sheet 3 phases behavior?

Note: Read the edits at the bottom OK, I’ve found a way to do it, but I had to change the code of multiple classes, so that the bottom sheet would know of the state of the appBarLayout (expanded or not), and ignore scroll-up in case it’s not expanded: BottomSheetLayout.java Added fields: private AppBarLayout mAppBarLayout; … 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

How can I add the new “Floating Action Button” between two widgets/layouts

Best practice: Add compile ‘com.android.support:design:25.0.1’ to gradle file Use CoordinatorLayout as root view. Add layout_anchorto the FAB and set it to the top view Add layout_anchorGravity to the FAB and set it to: bottom|right|end <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”match_parent”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <LinearLayout android:id=”@+id/viewA” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”0.6″ android:background=”@android:color/holo_purple” android:orientation=”horizontal”/> <LinearLayout android:id=”@+id/viewB” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_weight=”0.4″ … Read more