android-floating-action-button icon indicating copy to clipboard operation
android-floating-action-button copied to clipboard

Setting an OnFloatingActionsMenuUpdateListener causes expand animation to jitter.

Open IrisAmp opened this issue 10 years ago • 5 comments

It looks like the animation is being played, cancelled halfway through, then started again. I'm pretty confident that this is a bug and not some sort of API misuse (let me know if I'm horribly wrong).

Device Details

  • Nexus 5 LG D820
  • Android 5.1.0 LMY47I
  • Library version: 1.9.0

Code snippet

...
listView = (ListView) root.findViewById( R.id.a_main_listView );
fam = (FloatingActionsMenu) root.findViewById( R.id.a_main_fab );
overlay = root.findViewById( R.id.a_main_overlay );

// An animator I use to translate the FAM off screen when the list is scrolled.
// The graphical bug persists if this line is commented out.
famAnimator = new FloatingActionMenuAnimator( root, fam );
// An animator I use to fade the overlay in and out.
overlayAnimator = new ViewFadeAnimator( root, overlay );

//*
fam.setOnFloatingActionsMenuUpdateListener( new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener()
{
    @Override
    public void onMenuExpanded()
    {
        overlayAnimator.fadeIn();
    }

    @Override
    public void onMenuCollapsed()
    {
        overlayAnimator.fadeOut();
    }
} );//*/

overlay.setOnClickListener( new View.OnClickListener()
{
    @Override
    public void onClick( View view )
    {
        fam.collapse();
    }
} );
...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:fab="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".MainActivity">

...

    <com.getbase.floatingactionbutton.FloatingActionsMenu
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_margin="@dimen/margin"
        fab:fab_addButtonColorNormal="@color/blue_500"
        fab:fab_addButtonColorPressed="@color/blue_A100"
        fab:fab_labelStyle="@style/AppTheme.MenuLabels"
        fab:fab_labelsPosition="left">

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            fab:fab_colorNormal="@color/blue_500"
            fab:fab_colorPressed="@color/blue_A100"
            fab:fab_size="mini"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            fab:fab_colorNormal="@color/blue_500"
            fab:fab_colorPressed="@color/blue_A100"
            fab:fab_size="mini"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            fab:fab_colorNormal="@color/blue_500"
            fab:fab_colorPressed="@color/blue_A100"
            fab:fab_size="mini"/>

    </com.getbase.floatingactionbutton.FloatingActionsMenu>

...

</RelativeLayout>

IrisAmp avatar Apr 27 '15 02:04 IrisAmp

@IrisAmp I'm experience the same (or similar) problem with jerky animations when I fade in an overlay. Any ideas on a workaround?

myanimal avatar May 20 '15 13:05 myanimal

Are you setting the icon at the same time?

KlassenKonstantin avatar May 21 '15 07:05 KlassenKonstantin

@KlassenKonstantin no, I'm just using a ViewAnimator in the onMenuExpanded method to adjust the opacity of the view.

myanimal avatar May 21 '15 09:05 myanimal

DO LIKE THIS ANIMATION JERK WILL BE GONE
{ actionMenu.getAddButton().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (actionMenu.isExpanded()) { collapse(); } else { expand(); } } });

public void collapse() { mIsShowMenu = true; invalidateOptionsMenu(); setOverlay(false); new Handler().postDelayed(new Runnable() { @Override public void run() { actionMenu.collapse(); }

    }, 50);
}

public void expand() {
    mIsShowMenu = false;
    invalidateOptionsMenu();
    setOverlay(true);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            actionMenu.expand();

        }

    }, 50);
}

ammar-ali avatar Jan 06 '16 09:01 ammar-ali

It looks like the animation is being played, cancelled halfway through, then started again. I'm pretty confident that this is a bug and not some sort of API misuse (let me know if I'm horribly wrong).

Device Details

  • Nexus 5 LG D820
  • Android 5.1.0 LMY47I
  • Library version: 1.9.0

Code snippet

...
listView = (ListView) root.findViewById( R.id.a_main_listView );
fam = (FloatingActionsMenu) root.findViewById( R.id.a_main_fab );
overlay = root.findViewById( R.id.a_main_overlay );

// An animator I use to translate the FAM off screen when the list is scrolled.
// The graphical bug persists if this line is commented out.
famAnimator = new FloatingActionMenuAnimator( root, fam );
// An animator I use to fade the overlay in and out.
overlayAnimator = new ViewFadeAnimator( root, overlay );

//*
fam.setOnFloatingActionsMenuUpdateListener( new FloatingActionsMenu.OnFloatingActionsMenuUpdateListener()
{
    @Override
    public void onMenuExpanded()
    {
        overlayAnimator.fadeIn();
    }

    @Override
    public void onMenuCollapsed()
    {
        overlayAnimator.fadeOut();
    }
} );//*/

overlay.setOnClickListener( new View.OnClickListener()
{
    @Override
    public void onClick( View view )
    {
        fam.collapse();
    }
} );
...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:fab="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".MainActivity">

...

    <com.getbase.floatingactionbutton.FloatingActionsMenu
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_margin="@dimen/margin"
        fab:fab_addButtonColorNormal="@color/blue_500"
        fab:fab_addButtonColorPressed="@color/blue_A100"
        fab:fab_labelStyle="@style/AppTheme.MenuLabels"
        fab:fab_labelsPosition="left">

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            fab:fab_colorNormal="@color/blue_500"
            fab:fab_colorPressed="@color/blue_A100"
            fab:fab_size="mini"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            fab:fab_colorNormal="@color/blue_500"
            fab:fab_colorPressed="@color/blue_A100"
            fab:fab_size="mini"/>

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            fab:fab_colorNormal="@color/blue_500"
            fab:fab_colorPressed="@color/blue_A100"
            fab:fab_size="mini"/>

    </com.getbase.floatingactionbutton.FloatingActionsMenu>

...

</RelativeLayout>

Vokurecky avatar Sep 29 '18 12:09 Vokurecky