Reputation: 1712
This is my activity XML:
<?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:background="@android:color/white"
android:fitsSystemWindows="true">
<include layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/frameLayoutContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
I replace frameLayoutContainer
with a ConstraintLayout-rooted Fragment. It has a Button view at the bottom constrained with app:layout_constraintBottom_toBottomOf="parent"
But the Button view falls behind the navigation bar. I have many activities almost the same structure with this, but they don't have such a problem.
When I replace CoordinatorLayout with a LinearLayout, the problem is solved, but I want to know what is wrong with CoordinatorLayout?
Upvotes: 1
Views: 636
Reputation: 1506
The line app:layout_behavior="@string/appbar_scrolling_view_behavior"
does all the job. Try to remove this line from your XML file and you will see that the problem happens even if you do not replace frameLayoutContainer
with Fragment
.
Thus, the solution is to add this line app:layout_behavior="@string/appbar_scrolling_view_behavior"
to your root of Fragment (either in your XML or programmatically) and check it.
Upvotes: 2