user1462299
user1462299

Reputation: 4287

GooglePlay similar piece of interface

What kind of functionality is this ?

enter image description here

Is it FragmentPagerAdapter ? Is there any predefined styles/functionality to achieve just the same for API 10 ? Show me an example please.

Upvotes: 1

Views: 213

Answers (2)

Kevin Coppock
Kevin Coppock

Reputation: 134664

That's a PagerTitleStrip which is used with a ViewPager (so yes, your thought on FragmentPagerAdapter is correct if you want to use Fragments -- which you should, but I was lazy when I used it). Simply add the PagerTitleStrip as a child of your ViewPager like this:

<com.android.support.v4.view.ViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <com.android.support.v4.view.PagerTitleStrip
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dip"
        />
</com.android.support.v4.view.ViewPager>

And in your PagerAdapter that you write, be sure to override the getPageTitle() method. Android should handle everything else for you, although you'll have to style it manually if you want a custom font as shown, and the font color and background as shown.

It is included in the support library (right-click your project in Eclipse, choose Android Tools > Add Compatibility Package) and is compatible all the way back to API Level 4, so you will have no issues using it for API Level 10. The JakeWharton library being linked is overkill if you simply need the swiping title functionality -- his was developed before Google added the PagerTitleStrip to the compatibility library -- but does have some additional styles that you can use if so needed.

Upvotes: 4

mattdonders
mattdonders

Reputation: 1356

Jake Wharton has the ViewPagerIndicator if you would like - provides support for lower than 3.0 versions.

http://viewpagerindicator.com/

Upvotes: 1

Related Questions