Is there any way to set PagerSlidingTabStrip indicator width

628 Views Asked by At

Here i am using Android PagerSlidingTabStrip, and i want to know how to set its indicator width not full of its tab, such as set its indicator width 2/3 as its tab.

here is my xml configuration:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/viewItemWhiteBg">
    <include layout="@layout/default_header_actionbar" />
    <com.astuetz.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp"
        android:layout_height="40dp"
        app:pstsShouldExpand="true"
        app:pstsScrollOffset="20dp"
        app:pstsTabPaddingLeftRight="20dp"/>
    <android.support.v4.view.ViewPager
        android:id="@+id/infoTypePager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>

I had set its margin, but margin setting just changes tab horizontal location and set padding make no effect on its indicator.so anybody can tell me how to set its indicator width. Thank you.

1

There are 1 best solutions below

0
Aditi On

@Crabime there are certain attributes pstsIndicatorHeightHeight of the sliding indicator pstsUnderlineHeight Height of the full-width line on the bottom of the view pstsDividerPadding Top and bottom padding of the dividers pstsScrollOffset Scroll offset of the selected tab pstsTabBackground Background drawable of each tab, should be a StateListDrawable pstsShouldExpand If set to true, each tab is given the same weight, default false Refere the link:https://guides.codepath.com/android/sliding-tabs-with-pagerslidingtabstrip