I have a simple CoordinatorLayout
with a AppBarLayout
and FrameLayout
, but the FrameLayout
contents are being displayed over the AppBarLayout
regardless of the layout_behavior attribute on the FrameLayout
. I've tried adding that attribute elsewhere (like on my RecyclerView
), but it's the same behavior.
Here's a picture to show what I mean.
Activitiy Layout:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<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/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@android:id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Fragment Layout:
<android.support.v7.widget.RecyclerView
android:id="@+id/checkins_recycler_view"
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"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
How I add my fragment in my Activity:
final UserCheckinsFragment fragment = new UserCheckinsFragment();
final Bundle arguments = new Bundle();
UserCheckinsFragment.getArguments(arguments, items);
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment,
UserCheckinsFragment.class.getName()).commit();