Android: Sliding Menu Slide only content
Asked Answered
I

3

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);
Iroquoian answered 1/6, 2013 at 12:44 Comment(4)
i dont want the actionbar to hide. it must remain fixed and only the content below the actionbar slidesIroquoian
have your look at this..github.com/jfeinstein10/SlidingMenuNymph
@segi Actually he already useDepew
This question says the action bar doesn't slide if the Activity doesn't inherit from Sherlock__Activity and leave it as __ActivityLinares
T
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 !!

Tottering answered 1/6, 2013 at 13:5 Comment(15)
Now the whole sliding got disabled.Iroquoian
I'm extending SlerlockFragmentActivity and implementing SlidingActivtiyBase. Is this the problem/.Iroquoian
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 SlidingFragmentActivityTottering
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 ?Caracalla
@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.htmlTottering
@MehulJoisar i use this library : 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?Caracalla
@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.Tottering
@MehulJoisar never mind. i think i've found a way better library. written about it here: #18355401Caracalla
@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"Tottering
@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.Caracalla
@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.Tottering
@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...Caracalla
@androiddeveloper: it might be at initial stage right now.so google will include it when it become stable and robust.Tottering
@MehulJoisar interesting. do you know of other libraries by google developers that aren't officially available as google libraries ?Caracalla
let us continue this discussion in chatTottering
O
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.

Odyssey answered 30/9, 2013 at 22:3 Comment(0)
B
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.

Bridlewise answered 30/6, 2013 at 13:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.