5

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);
Ahmad
  • 69,608
  • 17
  • 111
  • 137
Lalith Mohan
  • 3,836
  • 5
  • 21
  • 36

3 Answers3

8

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 !!

Mehul Joisar
  • 15,348
  • 6
  • 48
  • 57
  • 1
    Now the whole sliding got disabled. – Lalith Mohan Jun 01 '13 at 13:23
  • I'm extending SlerlockFragmentActivity and implementing SlidingActivtiyBase. Is this the problem/. – Lalith Mohan Jun 01 '13 at 13:26
  • First of all,go through `http://stackoverflow.com/questions/16790187/sliding-menu-example-not-working-java-lang-illegalstateexception-randomlist-m/16790845#16790845` and yes,you need to extend `SlidingFragmentActivity` – Mehul Joisar Jun 01 '13 at 13:46
  • speaking of youtube, how do you make the sliding menu to let the content (the part on the right) to avoid moving, so that the only moving part is the menu itself (the part on the left) ? also, how do you use the moving icon on the "up" button of the action bar ? – android developer Aug 21 '13 at 09:24
  • @androiddeveloper: kindly have a look at Sliding drawer,that is exactly what you want.`http://developer.android.com/design/patterns/navigation-drawer.html`..you can find example snippets from here: `http://developer.android.com/training/implementing-navigation/nav-drawer.html` – Mehul Joisar Aug 21 '13 at 09:42
  • @MehulJoisar i use this library : https://github.com/jfeinstein10/SlidingMenu , because it allows the touch to start anywhere on the screen , and not just on the left area. it seems that youtube has all the features combined somehow. if i use the official library, how can i get this feature to work? – android developer Aug 21 '13 at 10:03
  • @androiddeveloper: I have gone through the example.in official library,you might implement Gesture listener on your fragment and on right swipe,you can communicate with Activity so that drawer can be open. – Mehul Joisar Aug 21 '13 at 12:08
  • @MehulJoisar never mind. i think i've found a way better library. written about it here: http://stackoverflow.com/questions/18354901/mimicking-the-navigation-drawer-of-youtube-app/18355662?noredirect=1#comment26949336_18355662 – android developer Aug 21 '13 at 12:52
  • @androiddeveloper:Nice library,btw he has done exactly what I had suggested you,have a look at `onInterceptTouchEvent` method of following class `"https://github.com/SimonVT/android-menudrawer/blob/master/menudrawer/src/net/simonvt/menudrawer/OverlayDrawer.java"` – Mehul Joisar Aug 21 '13 at 13:37
  • @MehulJoisar your link doesn't work. also, i think this library has more to offer than what google has done... sadly, i am having problems using it with maven. – android developer Aug 21 '13 at 13:38
  • @androiddeveloper: yes,afterall Simon is employee of Google itself.and I don't know,even when I copy the link from my comment,it gets broken.Anyways,you can locate that class in the path which is mentioned in my comment. – Mehul Joisar Aug 21 '13 at 13:47
  • @MehulJoisar yes well according to what i see, i'm happy that someone else did this great job... :) wonder why it's not a part of the official library of google if it's that good... – android developer Aug 21 '13 at 14:18
  • @androiddeveloper: it might be at initial stage right now.so google will include it when it become stable and robust. – Mehul Joisar Aug 22 '13 at 05:38
  • @MehulJoisar interesting. do you know of other libraries by google developers that aren't officially available as google libraries ? – android developer Aug 22 '13 at 06:36
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/35972/discussion-between-mehul-joisar-and-android-developer) – Mehul Joisar Aug 22 '13 at 06:44
2

According to the developer on GitHub:

SlidingMenu Integration

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.

bassicplays
  • 328
  • 1
  • 7
  • 21
0

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.

user1060418
  • 215
  • 1
  • 3
  • 15