Android: Sliding Menu Slide only content

故事扮演 提交于 2019-12-10 14:54:12

问题


I'm using Sliding Menu with ActionBarSherlock in my application. The actionbar and sliding menu works fine, but i want the sliding menu to slide only the content and not the actionbar like the latest version of youtube application.

Is this possible with slidingmenu? If yes, please tell how

Thanks in advance

Below is my code for actionbar and slidingmenu

    getSlidingMenu().setSlidingEnabled(true);
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
    getSlidingMenu().setBehindScrollScale(0.25f);
    getSlidingMenu().setFadeDegree(0.35f);
    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

回答1:


Solution:

        setSlidingActionBarEnabled(false);

Reference:

Have a look at example

your final code will look something like this after adding the suggested solution,

getSlidingMenu().setSlidingEnabled(true);
getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
getSlidingMenu().setShadowDrawable(R.drawable.shadow);
getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
getSlidingMenu().setBehindScrollScale(0.25f);
getSlidingMenu().setFadeDegree(0.35f);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);

        setSlidingActionBarEnabled(false);

I hope it will be helpful !!




回答2:


According to the developer on GitHub:

Look at step 1. You have 2 options, SlidingMenu.SLIDING_WINDOW or SlidingMenu.SLIDING_CONTENT.

SLIDING_WINDOW will include the Title/ActionBar in the content section of the SlidingMenu, while SLIDING_CONTENT does not.




回答3:


I tried with the solution given . But it does not work.

I am using SherlockActionBar and SlidingMenu together. It works good when I am not setting anything for setSlidingActionBarEnabled method. But it slides the whole window , I want to make it slide only when content is swiped.

So I called this method : setSlidingActionBarEnabled(false);

This has couple of issues :

  1. This makes the app show a blank white page when it is loaded first. I have multiple tabs shown in action bar , so the first tab is shown as selected but the content is empty.
  2. If I slide when say I am in tab 2 , then the back page (or behind page) content is visible but it also overlaps with what is shown currently on tab2.

Any pointers would be helpful.



来源:https://stackoverflow.com/questions/16872852/android-sliding-menu-slide-only-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!