How do I make tabs for a ViewPager now that ActionBar tabs are deprecated (Lollipop) [duplicate]

筅森魡賤 提交于 2019-12-20 11:52:57

问题


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:

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/26532415/how-do-i-make-tabs-for-a-viewpager-now-that-actionbar-tabs-are-deprecated-lolli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!