Setting an OnFloatingActionsMenuUpdateListener causes expand animation to jitter.
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 I'm experience the same (or similar) problem with jerky animations when I fade in an overlay. Any ideas on a workaround?
Are you setting the icon at the same time?
@KlassenKonstantin no, I'm just using a ViewAnimator in the onMenuExpanded method to adjust the opacity of the view.
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);
}
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>