Reputation: 23
I have the problem that my Floating Action Button is not overlapping over the Bottom Sheet in a Coordinator Layout. How can I solve this problem? The underlying layout is a Map Fragment.
The XML looks a following:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButtonAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-32dp"
android:layout_gravity="end|top"
android:src="@drawable/ic_add_white_48dp"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:elevation="4dp"
app:fabSize="normal"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/linear_layout_bottom_sheet">
<!-- include bottom sheet -->
<include layout="@layout/bottom_sheet_peek" />
<!-- include main content -->
<include layout="@layout/bottom_sheet_content" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Upvotes: 0
Views: 1728
Reputation: 76
Try set positive marginTop at LinearLayout and remove negative one from FAB:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButtonAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:src="@drawable/ic_add_white_48dp"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:elevation="4dp"
app:fabSize="normal"/>
<LinearLayout
android:layout_marginTop="32dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/linear_layout_bottom_sheet">
<!-- include bottom sheet -->
<include layout="@layout/bottom_sheet_peek" />
<!-- include main content -->
<include layout="@layout/bottom_sheet_content" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Upvotes: 1