16

I've seen that PagerTabStrip is a method of displaying tabs for a ViewPager. And now that ActionBar has been deprecated for Toolbar, it seems that the PagerTabStrip is my only option.

Except, I only see it comes out in the following style: enter image description here

I really just want normal tabs (with icons) the way I could do it with the ActionBar before like this:

enter image description here

What is the proper way of doing this now? Should I use an old TabWidget and add tabs manually? Or is there a way of styling the PagerTabStrip that I didn't know about?

EDIT: Here's the library I ended up using: https://github.com/neokree/MaterialTabs

Keith
  • 3,754
  • 7
  • 23
  • 40
  • 1
    There are independent indicators, such as the ViewPagerIndicator library, `PagerSlidingTabStrip`, and others, available as open source projects. You can also write your own indicator. – CommonsWare Oct 23 '14 at 16:14
  • Is the action bar really deprecated? – Kristy Welsh Oct 23 '14 at 16:34
  • Thanks for the link; I looked through that post before but didn't seem to find quite the right answer. I updated my question with an example of the result I'm going for. Unfortunately `PagerTabStrip` only seems to show the short strip with text to the far sides – Keith Oct 24 '14 at 04:14
  • @Prodikl I have been struggling with this same UX question. I have yet to find a good answer :( – AG1 Jan 18 '15 at 00:59
  • @AG1 hey, here's the library i ended up using: https://github.com/neokree/MaterialTabs – Keith Jan 18 '15 at 15:47
  • @Prodikl I ended up hacking mine together from the high-level overview in this answer. http://stackoverflow.com/questions/26803835/slidingtablayout-to-fit-the-screen The backwards compatibility team at Google should provide this functionality in a library, I spent ~3 hours tweaking mine to work the way I wanted. – AG1 Jan 19 '15 at 04:33

1 Answers1

8

Have a look at SlidingTabLayout from Google I/O Android App. It depends on SlidingTabStrip.

You can see how it's used by doing a simple search: you add it to your layout and then just connect it with your ViewPager like so:

slidingTabLayout.setViewPager(viewPager);

There is a way to setCustomTabView to customize the tabs.

Egor Neliuba
  • 14,144
  • 7
  • 55
  • 71
  • Thanks for that. That doesn't seem quite what I'm looking for. Ideally I'd be able to just add icons to tabs. I've updated my original question with an image example of what I'm looking for. Thanks again! – Keith Oct 24 '14 at 04:17
  • 1
    Does this solution play nice with Toolbar? – IgorGanapolsky Jan 12 '15 at 18:10