3

I'm trying to add the new(ish) android.support.design.widget.FloatingActionButton to my project but I'm having some difficulty. On pre-lollipop devices, the action button looks fine. On lollipop devices, it's docked to the bottom of the window, which means it is halfway cut off by the navigation bar at the bottom.

Note that I'm trying to add a FAB similar to the Gmail app where it is docked to the bottom right corner of the screen.

What I'm I doing wrong? My XML file:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="true" >

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/bg_color"
            android:longClickable="true"
            android:choiceMode="multipleChoice" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="60dp"
            android:layout_height="60dp"
            app:borderWidth="0dp"
            android:layout_margin="@dimen/fab_margin"
            android:elevation="44dp"
            android:clickable="true"
            android:onClick="onAddButtonClick"
            android:src="@drawable/ic_fab"
            android:layout_gravity="bottom|right|end"
            android:adjustViewBounds="false"
            android:baselineAlignBottom="true" />

    </android.support.design.widget.CoordinatorLayout>
</ScrollView>
0xMatthewGroves
  • 3,181
  • 3
  • 26
  • 43
  • try change android:layout_gravity="bottom|right|end" to android:layout_gravity="top|right" – sachithkn Jul 29 '15 at 06:41
  • I'm trying to dock it at the bottom right, top right wouldn't make any sense. – 0xMatthewGroves Jul 29 '15 at 06:45
  • Try removing the scrollview – Nishant Jul 29 '15 at 06:55
  • Removing the scrollview makes the xml file cleaner, but sadly doesn't solve my problem :( – 0xMatthewGroves Jul 29 '15 at 07:00
  • This may help you. http://stackoverflow.com/questions/19156476/how-to-put-list-items-at-the-bottom-of-list-view-in-navigation-drawer-like-fours?answertab=votes#tab-top – sachithkn Jul 29 '15 at 07:18
  • I did try tinkering with alignParentBottom and different combinations of layout_gravities, but I'm still hitting this issue. It sure looks like layout_gravity is docking at the bottom right of the view *window* but it's not accounting for that navigation bar. – 0xMatthewGroves Jul 29 '15 at 07:34
  • Try adding android:fitSystemWindows = true to your coordinator layout – Nishant Jul 29 '15 at 13:45
  • Still no luck. Was hopeful on this one, documentation made it seem this would solve my problem. But it does not. – 0xMatthewGroves Jul 29 '15 at 17:42
  • It seems there is a issue in Fab.. what you can do this add padding bottom to your coordinator layout or wrap the floating action button with a relative layout. – srinivasan Jul 31 '15 at 09:08

0 Answers0