Not able to fix PagerTitleStrip in android -


the pagertitlestrip overflowing. not able see title @ time. not able make out missing here. have attached screenshots. pagetitlestripexample - 3 titles not seen @ same time.

also how add material ui theme these tabs. library required , how apply theme tab or entire application

my adapter code

public class myadapter extends fragmentpageradapter { int totalfragments = 3;  public myadapter(fragmentmanager fm) {     super(fm); }  @override public fragment getitem(int position) {     return myfragment.newinstance(position); }  @override public int getcount() {     return totalfragments; }  @override public charsequence getpagetitle(int position) {     switch (position) {     case 0:         return "tab one";     case 1:         return "tab two";     case 2:         return "tab three"; }  return null; } } 

layout file:

 <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"   android:layout_width="fill_parent"   android:layout_height="fill_parent"   android:orientation="vertical" >    <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="0.3"     android:orientation="vertical" > </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="0.7"     android:orientation="vertical" >      <android.support.v4.view.viewpager         xmlns:android="http://schemas.android.com/apk/res/android"         android:id="@+id/pager"         android:layout_width="match_parent"         android:layout_height="match_parent" >          <android.support.v4.view.pagertitlestrip             android:id="@+id/pager_title_strip"              android:scrollbarsize="200dp"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_gravity="top"             android:background="#33b5e5"             android:paddingbottom="4dp"             android:paddingtop="4dp"             android:textcolor="#fff" />      </android.support.v4.view.viewpager>  </linearlayout>   </linearlayout> 

first, have used fill_parent, replace match_parent, since filling deprecated.

second, common settings viewpager size are

    android:layout_width="match_parent"     android:layout_height="0px" 

and possibly

    android:layout_weight="1" 

after these, pagertitlestrip, try

android:layout_width="wrap_content" 

third, material way of designing tabbed vies tablayout, google has tutorials , examples for.


Comments