SAVVY
SAVVY

Reputation: 850

How to set text style in pager title strip

I am trying to set the style and size of my pager title strip .But I am able to set only the text color and size but I am not able to set the style how to set different style in the pager title strip. here is what i tried

Style

 <style name="AppTheme.my" parent="Base.TextAppearance.AppCompat.Caption">
    <item name="android:textColor">@color/text</item>
    <item name="android:textSize">@dimen/text</item>
    <item name="android:typeface">serif</item>
</style>

<android.support.v4.view.PagerTitleStrip
        android:id="@+id/title"
        style="@style/AppTheme.my"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_marginTop="15dp"
        android:background="#fb263238"
        android:alpha="0.3"
        android:paddingTop="4dp"
        />

my java pager title

  public CharSequence getPageTitle(int position) {
    String title = new String();
    if (position == 0) {
        return "ALBUMS";
    }
    if (position == 1) {
        return "ARTISTS";
    }
    if (position == 4) {
        return "PLAYLIST";
    }
    if (position == 3) {
        return "GENRES";
    }
    if (position == 2) {
        return "SONGS";
    }
    return title;
}

what I am doing wrong and how I can set the text style in the pager title strip??

Upvotes: 0

Views: 587

Answers (1)

Chait
Chait

Reputation: 677

I have modified your code. Can you check with below code.

<android.support.v4.view.PagerTitleStrip
    android:id="@+id/title"
    style="@style/stylePagerTitleStrip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:layout_marginTop="15dp"
    android:background="#fb263238"
    android:alpha="0.3"
    android:paddingTop="4dp"
    />
 <style name="stylePagerTitleStrip">
    <item name="android:textColor">@color/text</item>
    <item name="android:textSize">@dimen/text</item>
    <item name="android:fontFamily">sans-serif</item>
</style>

Upvotes: 0

Related Questions