CoordinatorLayout
suggest changeCoordinatorLayout is a FrameLayout with extra capabilities. The official docs call it a super-powered FrameLayout.
A CoordinatorLayout.Behavior on a direct child can intercept touch events, window insets, measurement, layout, and nested scrolling.
Add the Design Support Library in the module dependencies block. Current versions are listed here.
dependencies {
compile 'com.android.support:design:25.3.1'
}
One use is a RecyclerView in a SwipeRefreshLayout, with a FloatingActionButton on top:
<?xml version="1.0" encoding="utf-8"?>
<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/coord_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycler_view"/>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="@mipmap/ic_add_white"
android:layout_gravity="end|bottom"
app:backgroundTint="@color/colorAccent"/>
</android.support.design.widget.CoordinatorLayout>
android:layout_gravity="end|bottom" places the button. app:layout_anchorGravity does nothing unless app:layout_anchor names another child. android:color is not a FloatingActionButton attribute. Use app:backgroundTint.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents