【问题标题】:Is there any way to set PagerSlidingTabStrip indicator width有没有办法设置 PagerSlidingTabStrip 指标宽度
【发布时间】:2017-04-28 02:33:26
【问题描述】:

这里我使用的是 Android PagerSlidingTabStrip,我想知道如何设置它的指示器宽度不填满它的选项卡,例如将它的指示器宽度设置为 2/3 作为它的选项卡。

这是我的 xml 配置:

 <?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>

我已经设置了它的边距,但是边距设置只是改变了选项卡的水平位置,并且设置的填充对其指示器没有影响。所以任何人都可以告诉我如何设置它的指示器宽度。谢谢。

【问题讨论】:

    标签: android pagerslidingtabstrip


    【解决方案1】:

    @Crabime 有一定的属性 pstsIndicatorHeightHeight 滑动指示器的高度 pstsUnderlineHeight 视图底部全角线的高度 pstsDividerPadding 分隔线的顶部和底部填充 pstsScrollOffset 所选标签页的滚动偏移量 pstsTabBackground 每个tab的背景drawable,应该是StateListDrawable pstsShouldExpand 如果设置为 true,每个选项卡被赋予相同的权重,默认为 false 参考链接:https://guides.codepath.com/android/sliding-tabs-with-pagerslidingtabstrip

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-16
      • 1970-01-01
      • 1970-01-01
      • 2013-03-10
      • 2011-04-10
      • 2012-03-29
      相关资源
      最近更新 更多