Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move the actionbar sherlock with drawer navigation menu

I have implemented the new drawer with actionbar sherlock, and appretantly the actionbar stays at the same state.

I have implemented the ActionBarDrawerToggle interface to handle the open/close callbacks.

    actionBarDrawerToggle = new ActionBarDrawerToggle(this, menu, R.drawable.ic_launcher,
            R.string.app_name, R.string.app_name) {
        @Override
        public void onDrawerOpened(View drawerView) { 
            super.onDrawerOpened(drawerView);
            drawerOpened = true;
            sliderButton.setBackgroundResource(R.drawable.tab_bar_menu_icon_push);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            drawerOpened = false;
            sliderButton.setBackgroundResource(R.drawable.tab_menu);
        }
    };
    menu.setDrawerListener(actionBarDrawerToggle);

How to I set the actionbar to move as well with the drawer menu?

like image 293
user1940676 Avatar asked Jun 16 '13 07:06

user1940676


2 Answers

the questions seems a bit confusing for me but I guess it's very simple answer if you have the correct links and a bit of history, which I'll try to provide here:

As you can see on the official design guidelines >>>LINK<<<: the drawer is supposed to cover the main content and both the ActionBar and the content is to stay fixed, not moving at all. The only element that moves on the screen is the actual drawer.

But this pattern was only released a month ago during the Google I/O 2013. Before that, each Google app was doing whatever the developers wanted to do on that moment. And now that the Google I/O have passed, they're all running to adequate to the official guidelines (most of them are already updated, for example Gmail and G+).

If you do not want to follow the official guideline and want to make the whole app (both ActionBar and content) to move out of the screen when the drawer is open, the easiest way is to use the excellent SlidingMenu library >>>LINK<<<. And if you read the examples and search around the web, I'm sure you'll find the way to implement it.

If you want to follow the official guideline, but also want to use the ActionBarSherlock (that's what I'm doing in my current project) you can find an ActionBarDrawerToggle compatible with ActionBarSherlock here in this GIT pull request on the official project >>>LINK<<< but this pull request was not accepted so then you can either copy the code from there and put on your project or you can use this fork from the original ActionBarSherlock here >>>LINK<<< that the guy already implemented and already applied the fix I suggested.

I hope this answers your question.

like image 184
Budius Avatar answered Nov 18 '22 01:11

Budius


I was reading a similar question to this recently. It may give some answers: How did Google manage to do this? Slide ActionBar in Android application

like image 31
eoinzy Avatar answered Nov 18 '22 02:11

eoinzy