TabPageIndicator : want to have custom height, not wrap_content. Title of Tab not showing full text

2.9k Views Asked by At

I am using TabPageIndicator with ViewPager, referred from here. My layout XML is as follow:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

     <com.viewpagerindicator.TabPageIndicator
        android:id="@+id/indicator"
        android:layout_height="35dp"
        android:layout_gravity="center_vertical"
        android:layout_width="fill_parent"
        android:paddingTop="0dp"
        android:paddingBottom="0dp"
        android:layout_margin="0dp"
        android:background="#69cbd8"
        />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        />

</LinearLayout>

And in Manifest, the activity is defined as follow :

        <activity
            android:name=".modules.results.ResultsLauncher"
            android:configChanges="orientation|screenSize"
            android:theme="@style/StyledIndicators">
            >
            <!-- android:label="Titles/With Listener" -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="com.jakewharton.android.viewpagerindicator.sample.SAMPLE" />
            </intent-filter>
        </activity>

As you can see, I had used custom style, StyledIndicators. I had referred samples downloaded from GITHUB & referred a custom style from here.

Now everything works fine. But the bottom of title of Tab is being covered. And leaving unnecessary space above. I am not able to display whole title of tab. I had attached screen shot of my screen.

I want the title "By Date" & " By Test" to be placed little bit in upper part. But couldn't find the solution.

enter image description here

1

There are 1 best solutions below

0
On

in order to fully control your tabPageIndicator:

create XML file and inflate that xml in tabPageIndicator component

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <include
        android:id="@+id/tab_inbox"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        layout="@layout/tab_inbox" />

    <include
        android:id="@+id/tab_dialer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        layout="@layout/tab_dialer" />
</LinearLayout>

and from the code inflate that layout