Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PagerTabStrip not showing in ViewPager in app targeting Android 6.X (N)

I have an existing app that makes use of ViewPager and PagerTabStrip and this has been working for a long time with various releases of the Android SDK and the com.android.support:appcompat-v7 library. I've just bumped up the compile and target SDK versions of my app from 23 to 24 and the com.android.support:appcompat-v7 library version from 23.4.0 to 24.0.0... and I now see that the PagerTabStrip is totally missing from the ViewPager. (Not just missing titles in the PagerTabStrip... the PagerTabStrip is totally missing from the ViewPager when the views are rendered.)

This is how I'm declaring the ViewPager and PagerTabStrip views in my layout file:

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.v4.view.PagerTabStrip
        android:id="@+id/pagerTabStrip"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:textColor="@android:color/white"
        android:background="@color/view_bg_blue" />

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

Can anyone spot something that I'm doing wrong or could this be a bug in ViewPager and PagerTabStrip?

like image 583
Adil Hussain Avatar asked Dec 05 '22 17:12

Adil Hussain


1 Answers

This is the temporary workaround until the issue is resolved in the Android support library:

((ViewPager.LayoutParams) pagerTabStrip.getLayoutParams()).isDecor = true;

See here for a fuller discussion on the status of the issue: https://code.google.com/p/android/issues/detail?id=213359

like image 190
Adil Hussain Avatar answered Dec 08 '22 08:12

Adil Hussain