I'm trying to use Sliding Menu in my application. On my Sony Xperia S it works very nice, but when I try to launch app on HTC Desire HD, menu opens perfect by gesture, but other touch events are blocked and top view (ViewPager
, sliding menu is behind it) is not scrolling.
Does anybody know how to fix this?
May be it will be helpful to give an answer (This is how I'm using menu):
private void initSlidingMenu()
{
mSlidingMenu = new SlidingMenu(getApplicationContext());
mSlidingMenu.setMode(SlidingMenu.LEFT);
mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
mSlidingMenu.setShadowWidthRes(R.dimen.default_shadow_width);
mSlidingMenu.setShadowDrawable(R.drawable.defaultshadow);
mSlidingMenu.setBehindOffsetRes(R.dimen.default_behind_offset);
mSlidingMenu.setFadeDegree(0.35f);
mSlidingMenu.setMenu(firstPage);
mSlidingMenu.attachToActivity(this,SlidingMenu.SLIDING_CONTENT);
}
In onPageSelected()
, I disable menu or enable it, so menu appears only at left page:
@Override public void onPageSelected(int arg0)
{
ActivityCompat.invalidateOptionsMenu(this);
if (arg0 == Utils.DEFAULT_PAGE)
mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
else
mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
}
I just had the same problem with the Sliding menu working fine on my Samsung Galaxy S2 running ICS but not on my HTC Desire running Gingerbread.
I used the same method as you to implement the sliding menu but I found that another implementation solved the problem.
Instead of manually attaching the menu to your activity :
I chose to extend my Activity by one of the Sliding activities from the SlidingMenu library. In my case, my Activity was extending
FragmentActivity
at first but I replaced it bySlidingFragmentActivity
Then you should set the behindView inside the
onCreate
method or your activity will crash.It should fix the problem.
Here is a sample code of my Activity :
You will note that with this solution you don't have to call
I haven't analyzed all the source code of the SlidingMenu library but maybe the current
attachToActivity
method is buggy in some cases and those bugs don't appear if we use the special activities provided by the library.EDIT : Ok for those who are working with the SlidingMenu library AND ActionBarSherlock (ABS). First you have to make sure that ABS is referenced in the SlidingMenu lib. That way, you'll be able to extend the activities classes provided by SlidingMenu by the ABS ones.
Example if I want to use an FragmentActivity with both ABS and Sliding menu : you have to change in the sliding menu library
by
And then in you application, use the
SlidingFragmentActivity
normally.Here is the code of my app, it is like the one I posted but with ABS support :