I am able to reproduce this issue by adding a LinearLayout view:
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2016 Yavor Ivanov
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<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:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="io.github.yavski.fabspeeddial.samples.PositionSampleActivity">
<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" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<io.github.yavski.fabspeeddial.FabSpeedDial
android:id="@+id/position_bottom_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:fabGravity="bottom_end"
app:fabMenu="@menu/menu_main"
app:touchGuard="false" />
<io.github.yavski.fabspeeddial.FabSpeedDial
android:id="@+id/position_bottom_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
app:fabGravity="bottom_start"
app:fabMenu="@menu/menu_main"
app:touchGuard="false" />
<io.github.yavski.fabspeeddial.FabSpeedDial
android:id="@+id/position_top_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|start"
app:fabGravity="top_start"
app:fabMenu="@menu/menu_main"
app:touchGuard="false" />
<io.github.yavski.fabspeeddial.FabSpeedDial
android:id="@+id/position_top_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
app:fabGravity="top_end"
app:fabMenu="@menu/menu_main"
app:touchGuard="true" />
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/test_layout"
android:visibility="gone"
android:layout_height="match_parent"
android:orientation="vertical"/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
to the bottom of the FrameLayout used in your activity_position_sample layout/demo app.
Screenshot:
As far as the code responsible for this bug, I am noticing that in this case, the FAB menu items are added to the menuItemsLayout twice. onAttachedToWindow is called twice, and no checks are done to ensure we are not re-adding items that are already present. I'm not sure why the existence of an extra LinearLayout would cause this to happen, but there are certain use cases where the FAB is not the top most item (an example: I want to display help/onboarding views which cover the entire screen with a semi-transparent view with info/details)
I am able to reproduce this issue by adding a LinearLayout view:
to the bottom of the FrameLayout used in your activity_position_sample layout/demo app.
Screenshot:
As far as the code responsible for this bug, I am noticing that in this case, the FAB menu items are added to the menuItemsLayout twice. onAttachedToWindow is called twice, and no checks are done to ensure we are not re-adding items that are already present. I'm not sure why the existence of an extra LinearLayout would cause this to happen, but there are certain use cases where the FAB is not the top most item (an example: I want to display help/onboarding views which cover the entire screen with a semi-transparent view with info/details)