Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we work-around the blank title in PagerTitleStrip and PagerTabStrip?

There's an issue with PagerTitleStrip and PagerTabStrip with support-v4 (version 23.0.0).

The title views of a ViewPager when using PagerTitleStrip or PagerTabStrip and the version 23.0.0 (for Marshmallow/Android 6.0 support) of the support-v4 library doesn't render correctly.

Issue is tracked and scheduled for Future Release on: https://code.google.com/p/android/issues/detail?id=183127 https://code.google.com/p/android/issues/detail?id=184715

Update: This have now been resolved, in 23.1.0.

like image 252
Sveinung Kval Bakken Avatar asked Sep 03 '15 14:09

Sveinung Kval Bakken


3 Answers

An interim solution while waiting for a patched release is to use a copy of the latest known good version of these classes (22.1.0) instead of the one bundled with the support library.

Drop the attached files into your project and setup your ViewPager with these classes instead.

Note: do not change their package name as they rely on package protected classes in the support library.

Example using our "new" PagerTabStrip class:

      <android.support.v4.view.ViewPager
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="wrap_content">   
          <android.support.v4.view.PagerTabStripV22
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="top"/>   
      </android.support.v4.view.ViewPager>

PagerTitleStripV22.java

PagerTabStripV22.java

like image 188
Sveinung Kval Bakken Avatar answered Nov 02 '22 06:11

Sveinung Kval Bakken


This issue was fixed in version 23.1.0

com.android.support:support-v4:23.1.0

like image 26
dercilima Avatar answered Nov 02 '22 06:11

dercilima


My "comment" as an answer so it's not overlooked.

First when you download the files from the links they will not be the correct file names i.e., the .java files will be missing the "V" for "V22", so you'll need to rename both files to "PagerTitleStripV22.java" and "PagerTabStripV22.java". Then follow these instructions posted by someone else: Create package "android.support.v4.view" in your project and drop the attached by #31 files into your project inside created package and change android.support.v4.view.PagerTabStrip to android.support.v4.view.PagerTabStripV22 in your layout file.

like image 2
Brandon Avatar answered Nov 02 '22 07:11

Brandon