Getting DrawerLayout to Slide over the ActionBar

前端 未结 10 1533
星月不相逢
星月不相逢 2020-12-02 09:46

I have a sliding drawer menu in an activity, which has an actionbar with some tabs on it.

I\'d like to get the sliding drawer to slide over the tabs , not below th

相关标签:
10条回答
  • 2020-12-02 10:05

    I managed to achieve this requirement by setting the navigationMode inside OnDrawerClosed and onDrawerOpened functions. It is a temp fix since the tabs actually do not disappear immediately.

      public void onDrawerClosed(View view) {
              getActionBar().setTitle(mTitle);
              if(getActionBar().getTabCount()>0) //Add tabs when the fragment has it
              getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);               
                            ...
                        }
    

       public void onDrawerOpened(View drawerView) {
                getActionBar().setTitle(mDrawerTitle);
                getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);              
                        ..
    
                        }
    

    If you have some fragments with tabs, and other without it don't forget to remove tabs onCreateView of fragment that does not have tabs.

     getActionBar().removeAllTabs();
    
    0 讨论(0)
  • 2020-12-02 10:11

    I have use tabs inside fragment of drawer. I solve this problem adding

    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); 
    

    in onDrawerClosed() and getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); in onDrawerOpend() method.

    I hope this will help you.

    0 讨论(0)
  • 2020-12-02 10:13

    you can use below libraries to get navigation model similar to Google play music app.

    • ActionBarSherlock (github)
    • nested-fragments (github)
    • PagerSlidingTabStrip (github)
    • NavigationDrawer (Android developer site)
    • Latest Support v4 library

    I have created a project Navigation Drawer with Tab Strip Example at github, have a look at it.

    Below is the screenshot of it.

    Navigation-drawer-page-sliding-tab-strip

    0 讨论(0)
  • 2020-12-02 10:16

    I had the same problem, but the only solution I found was to use tabs inside the inner fragment (not fragmentActivity). I don't know if it was the best solution, the only problem i had was styling this tabs, for the rest, it works perfectly

    0 讨论(0)
提交回复
热议问题