Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Google Play like tabs

Google has just implemented a new look to their tabs in Google Play.

I know this can be done with ViewPagerIndicator, yet I wouldn't like to use another library in my application and bump the app's size by another MB or so.

I am currently using the android.support.v4.view.PagerTabStrip (like in the old Google Play), and I'm wondering if the new look can also be implemented using the android support library.

Thanks in advance.

like image 445
MrByte Avatar asked May 14 '13 13:05

MrByte


People also ask

How do you make tabs on Android?

Tabs are created using newTab() method of TabLayout class. The title and icon of Tabs are set through setText(int) and setIcon(int) methods of TabListener interface respectively. Tabs of layout are attached over TabLayout using the method addTab(Tab) method.

What is the use of tab bar in Android?

A TabLayout provides a way to display tabs horizontally. When used together with a ViewPager , a TabLayout can provide a familiar interface for navigating between pages in a swipe view.


1 Answers

Design Support Library (current method).

The Design Support Library includes the TabLayout widget which allows you to implement a Google Play-lie tabs:

<android.support.design.widget.TabLayout     android:id="@+id/tabs"     android:layout_width="match_parent"     android:layout_height="wrap_content" /> 

and then initializing it:

TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); 

For a full example see the Cheesesquare app

PagerSlidingTabStrip Library

This is a ready-to-use library that you can find on Github.

ScreenshotScreenshot

like image 108
rciovati Avatar answered Oct 03 '22 23:10

rciovati