Android - Google Play as tabs

Google has just introduced a new look to its tabs on Google Play.

I know that this can be done using ViewPagerIndicator, but I would not want to use another library in my application and increase the size of the application by another MB or so.

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

Thanks in advance.

+24
android google-play tabs
May 14 '13 at 13:12
source share
3 answers

Design Support Library (current method).

The design support library includes a TabLayout widget that allows you to use the 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 initialize it:

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

See Cheesesquare App for a complete example.

PagerSlidingTabStrip Library

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

ScreenshothotScreenshothot

+49
May 14 '13 at
source share

Google has finally released its rolling api tabs.

To use SlidingTabsBasic, you first need to download the zip file from: http://developer.android.com/downloads/samples/SlidingTabsBasic.zip

  • Include the 2 java source files in the com.example.android.common.view package in your project. You can move them to a suitable package in your project.
  • To use a component, simply add it to your view hierarchy. Then, in your activity or fragment, provide SlidingTabsBasic with your viewPager by calling mSlidingTabLayout.setViewPager (mViewPager);

Google Layout Example:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.example.android.common.view.SlidingTabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" android:background="@android:color/white"/> </LinearLayout> 

Example code in the onCreate () method of your activity:

 mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs); mSlidingTabLayout.setViewPager(mViewPager); 

For more details see the example in the zip file SlidingTabsBasicFragment.java and fragment_sample.xml

+34
Feb 22 '14 at
source share

try this library

Project example

It uses a ViewPager with a snippet to display tabs, like in a google game.

+1
May 14, '13 at 13:16
source share



All Articles