【问题标题】:TabLayout scrollable tabs padding is calculated badlyTabLayout 可滚动选项卡填充计算错误
【发布时间】:2016-03-15 15:26:05
【问题描述】:

我们在 xml 中有这个 TabLayout:

<android.support.design.widget.TabLayout
    android:id="@+id/sliding_tabs"
    app:tabGravity="fill"
    app:tabContentStart="@dimen/tab_content_start"
    app:tabIndicatorColor="@color/MaterialDividerColor"

    app:tabSelectedTextColor="@color/DarkRed"
    app:tabTextColor="@color/Black"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

问题是,当在 平板电脑 上显示时,它看起来很奇怪,所有选项卡的宽度都相同,因此每个标签的内边距都大不相同:

令人惊讶的是,在手机上它按预期工作,或者至少问题不可见:

我正在使用 23.2.0 支持库,坦率地说,它看起来充满了错误。

【问题讨论】:

    标签: android material-design android-support-library android-tablayout


    【解决方案1】:

    当你有app:tabMode="scrollable"的TabLaout时,你需要给tabMinWidth一些值,比如app:tabMinWidth="40dp"。否则,选项卡填充将不起作用。

    【讨论】:

      猜你喜欢
      • 2018-11-16
      • 1970-01-01
      • 2015-12-12
      • 1970-01-01
      • 1970-01-01
      • 2015-08-28
      • 2018-03-22
      • 2021-03-28
      相关资源
      最近更新 更多