Clans / FloatingActionButton

Android Floating Action Button based on Material Design specification
Apache License 2.0
5.23k stars 1.13k forks source link

FloatingActionMenu in the bottom center of coordinator layout #427

Open jugalptl opened 6 years ago

jugalptl commented 6 years ago

I am trying to make FloatingActionMenu in the bottom center part of the Coordinator layout. I am using android:layout_gravity="bottom|center" for FAM but not working for me. Here is the XML code

<android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent">

    <com.github.clans.fab.FloatingActionMenu
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom|center"
        app:menu_fab_size="normal">
        <com.github.clans.fab.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/snack"/>

    </com.github.clans.fab.FloatingActionMenu>
</android.support.design.widget.CoordinatorLayout>

Any suggestions..?

MostafaPirhayati commented 6 years ago

I do this you can use a Linearlayout and then set gravity to LinearLayout

<LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|left"
        android:layout_margin="6dp"
        android:orientation="horizontal"
        app:layout_anchor="@+id/include"
        app:layout_anchorGravity="right|bottom">

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/find_my_place_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:layout_marginBottom="8dp"
            android:src="@mipmap/ic_loc"
            app:fab_colorNormal="#47a6f4"
            app:fab_colorPressed="#3a75bc"
            app:fab_colorRipple="#99FFFFFF"
            app:fab_shadowColor="#66000000"
            app:fab_showShadow="true" />
</LinearLayout>
faizan321 commented 5 years ago

have you find any solution. i also face the same issue.