Marshal Chen
Marshal Chen

Reputation: 2005

Android jfeinstein10/SlidingMenu's animation is not smooth when changes fragment

I use jfeinstein10/SlidingMenu as my slidingmenu for my app and the slidingmenu will change different fragment for a activity.When the fragment contains only one or two items it seems good.But if I tried to make the fragment contains more thing ,the slidingmenu will be a short stop when I change the fragment.The animation is not smooth

Is there anyway to slove the problem?Thanks.

Upvotes: 1

Views: 1189

Answers (2)

PaperThick
PaperThick

Reputation: 2799

I have a somewhat clunky solution for this but it works okay. I use a base class for my fragments which is called BaseFragment. In this class I override the onResume method and close the menu if it is showing:

@Override
public void onResume() {
    super.onResume();

    if(sm.isMenuShowing()){
        sm.showContent();
    }
}

sm is a reference for a SlidingMenu from the SlidingFragmentActivity.

This will make the animation smoother but it will create a small delay between the click on a menu button and the start of the close animation. In my case this worked better then when the animation stops mid-animation.

Upvotes: 1

user2041064
user2041064

Reputation: 131

I experience same animation lag when I'm showing heavy fragment. I tried to close menu with animation and show fragment with animation at same time. The animation was laggy, even with native drawer.

So the way to go is:

  1. set menuOnClose listener

  2. on menu item click remember the choice

  3. close menu

  4. in onCloseListener show fragment.

that works great for me.

Upvotes: 2

Related Questions