Poonam Anthony
Poonam Anthony

Reputation: 1988

displaying page titles in ViewPager

I'm developing an app using ViewPager and TitlePageIndicator of the ViewPagerIndicator. I'm using PagerTitleStrip to display the title of each page as shown in the screenshot below.

enter image description here

The titles are being displayed below the TitlePageIndicator, but I would like the titles to appear above the TitlePageIndicator. Is it possible to do so? Presently I'm using PagerTitleStrip to display the titles.

The layout of the main activity:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent" /> 
<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_below="@id/titles"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <android.support.v4.view.PagerTitleStrip
    android:id="@+id/title_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:paddingTop="4dp"
    android:paddingBottom="4dp" />

</android.support.v4.view.ViewPager>

</RelativeLayout>

Upvotes: 3

Views: 2116

Answers (1)

Saad Asad
Saad Asad

Reputation: 2528

it will be easier if you use android.support.v4.view.PagerTabStrip instead,like

<android.support.v4.view.PagerTabStrip
            android:id="@+id/pager_tab_strip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/pager"
            android:layout_gravity="top"
            android:background="#000000"
            android:paddingBottom="4dp"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:paddingTop="4dp"
            android:textColor="#ffffff" />

Upvotes: 4

Related Questions