Sherlock Action Bar with Sliding menu

2019-03-11 12:20发布

问题:

I'm making a view and an activity extending SherlockMapActivity and using SlidingMenu libraries to make my main view to scroll like Google+ does. I've added the SlidingMenu by XML and my view scrolls perfectly showing the hidden menu but it only scrolls the view below the action bar. In Google+ app it also scrolls the action bar and I've seen there's a function for making my action bar sliding enabled but it does not work.

What would be the best way to make my action bar sliding with the full view? Maybe I'm not extending the correct class?

This is how I add the SlidingMenu to my app:

XML File:

<com.slidingmenu.lib.SlidingMenu
    xmlns:sliding="http://schemas.android.com/apk/res-auto"
    android:id="@+id/slidingmenulayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    sliding:viewAbove="@layout/activity_main"
    sliding:viewBehind="@layout/menu_desplegado"
    sliding:behindOffset="120dip"
    sliding:behindScrollScale="0.25"
 />

And this is the result:

回答1:

I've solved my problem.

In order to make my Action Bar to Slide, I had to modify the SlidingMenu this way:

  1. Checkout a clean copy of ActionBarSherlock and import into your Eclipse workspace.
  2. Add ActionBarSherlock as a dependency to SlidingMenu.
  3. Go into the SlidingActivities that you plan on using make them extend Sherlock__Activity instead of __Activity.

Then I extended my MainActivity from SlidingMapActivity and it worked perfectly.



回答2:

Okay I think I found your answer. Try checking out this project on github: https://github.com/jfeinstein10/SlidingMenu

Here is a video of it in action: http://www.youtube.com/watch?v=8vNaANLHw-c&feature=youtu.be



回答3:

In my case, I prefer to add this slideMenu in code.

Well, when you create this SlideMenu:

menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);

then set this line too:

menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);

This makes the magic!.



回答4:

Here is a complete project developed by me for easy sliding menu developer http://github.com/leonardosalles/shipp-sliding-menu