zendesk / android-floating-action-button

Floating Action Button for Android based on Material Design specification
Apache License 2.0
6.38k stars 1.45k forks source link

FAM view group size issue with labels and FABs #162

Open pcsantana opened 9 years ago

pcsantana commented 9 years ago

Hi,

First, congratulations for the great job! It's a awesome library.

So, I'm trying to use the FAM, but I realized that when I have more FABs or Labels, the view group size of FAM wrap it even if the FAM is closed. It's a issue for me because if I have ui elements under the FAM (like buttons, list with scroll) I can't click it or scroll it!

I setted the red background to be easier to see the problem. I'm doing something wrong?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/reports_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="16dp"
        android:textSize="@dimen/text_size_xlarge"
        android:text="Customers" />

    <com.getbase.floatingactionbutton.FloatingActionsMenu
        android:id="@+id/multiple_actions"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:background="@color/red"
        app:fab_addButtonColorNormal="@color/colorPrimary"
        app:fab_addButtonColorPressed="@color/colorPrimaryDark"
        app:fab_addButtonPlusIconColor="@color/white"
        app:fab_labelStyle="@style/menu_labels_style"
        android:layout_marginBottom="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginEnd="16dp">

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:id="@+id/action_edit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fab_icon="@drawable/ic_edit"
            app:fab_colorNormal="@color/green"
            app:fab_title="Action 1"
            app:fab_size="mini"
            app:fab_colorPressed="@color/white_pressed"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:id="@+id/action_charge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fab_icon="@drawable/ic_edit"
            app:fab_colorNormal="@color/red"
            app:fab_title="Action little long"
            app:fab_size="mini"
            app:fab_colorPressed="@color/white_pressed"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:id="@+id/action_rent"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fab_icon="@drawable/ic_edit"
            app:fab_colorNormal="@color/orange"
            app:fab_title="Action 3"
            app:fab_size="mini"
            app:fab_colorPressed="@color/white_pressed"/>

    </com.getbase.floatingactionbutton.FloatingActionsMenu>
</RelativeLayout>

Screenshots:

https://www.dropbox.com/s/18sndsvo8wkaig1/Screenshot_2015-03-22-16-38-31.png https://www.dropbox.com/s/qan09dhkkmpqb66/Screenshot_2015-03-22-16-38-39.png

Thank you!

CodeBendr commented 9 years ago

I also have the same issue, Have you been able to resolve yours? I tried changing the width and height to 0dp but doesn't seem to work.

pcsantana commented 9 years ago

Not yet :( and you? I tried some things but nothing that solved the problem. So I started to do other things meanwhile.

TheZ3ro commented 9 years ago

I think the problem is because the Visibility isn't set to GONE when performing the animation. The whole library avoids the use of GONE status, keeping the FAB Invisible but still in the ViewGroup's View.

The solution maybe is setting the FAB's visibility to GONE, BUT in this case the FAB will not be animated 'cause --> FloatingActionsMenu.java#L221 - FloatingActionsMenu.java#L303 - FloatingActionsMenu.java#L376

pcsantana commented 9 years ago

Hi folks,

I found the solution. Actually I was doing wrong. The cause of my problem is because I was setting "setOnClickListener" to FAM. If I remove this event listener, everything go as expected.

Now I'm using "setOnFloatingActionsMenuUpdateListener" :)

dejiapps commented 7 years ago

I anyone is still having issues with this, I fixed my issue by setting the small/sub Fabs + labels to gone when the FabMenu is collapsed, and visible when the FabMenu is expanded. I also added a very slight delay to when the sub fabs are set to gone on FabMenu collapse so that the disappearing animation is not affected.