Getting DrawerLayout to Slide over the ActionBar

2019-01-10 07:52发布

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 them.

This is what it looks like right now...

Sliding menu under action bar tabs

Any ideas on how this could be done?

Note: I understand that I might be breaking some conventions and UI patterns here, and if it does not work at all, I'll look at alternatives. But I'd like to get this working first.

EDIT: See the below screen shot of the Google Play Music app that does exactly what I need. See @CommonsWare's answer below where he does agree that I might be breaking convention. But then given the Play Music app, it may not be altogether that rare either.

Proper navigation with tabs sliding correctly

10条回答
女痞
2楼-- · 2019-01-10 08:06

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

查看更多
看我几分像从前
3楼-- · 2019-01-10 08:12

This can be done WITHOUT a Third party library. Check out Google's Sliding Tabs samples

     SlidingTabsBasic:   http://developer.android.com/samples/SlidingTabsBasic/project.html
     SlidingTabsColors:  http://developer.android.com/samples/SlidingTabsColors/project.html

Also, check out this awesome link: http://manishkpr.webheavens.com/android-sliding-tabs-example/ Worked like a charm for me. :)

查看更多
男人必须洒脱
4楼-- · 2019-01-10 08:14

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.

查看更多
姐就是有狂的资本
5楼-- · 2019-01-10 08:15

Any ideas on how this could be done?

Do any of the following:

  • Switch away from action bar tabs, perhaps to ViewPager and a tabbed indicator (PagerTabStrip, TabPageIndicator from ViewPageIndicator)

  • See if an existing third-party drawer implementation has not yet updated to the new UI standards

  • Fork DrawerLayout and modify it to suit

  • Roll your own navigation drawer from scratch

I understand that I might be breaking some conventions and UI patterns here

Correct.

查看更多
等我变得足够好
6楼-- · 2019-01-10 08:16

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

查看更多
太酷不给撩
7楼-- · 2019-01-10 08:17

Check also this library http://www.androidviews.net/2013/04/pager-sliding-tabstrip/ The guy did a great job. You can use it with a navigation drawer and it works perfectly.

查看更多
登录 后发表回答