【问题标题】:Set tab indicator height to match parent/tab height设置标签指示器高度以匹配父/标签高度
【发布时间】:2021-10-25 17:35:05
【问题描述】:

有什么方法可以将标签指示器的高度设置为 android 中的标签高度?

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/camera_mode_tabs"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        app:tabIndicator="@drawable/mode_indicator"
        app:tabGravity="center"
        app:tabIndicatorHeight="30dp"
        />

我可以通过将 layout_height 和 tabIndicatorHeight 硬编码为 30dp 来实现。但是有没有更好的方法呢?使用 wrap_content 或类似的东西。

【问题讨论】:

    标签: java android xml android-tablayout


    【解决方案1】:

    迟到的答案,但你可以使用

    app:tabIndicatorGravity="stretch"
    

    【讨论】:

      猜你喜欢
      • 2017-11-23
      • 2011-02-13
      • 2014-10-30
      • 2016-10-19
      • 2015-10-25
      • 1970-01-01
      • 2016-09-20
      • 2013-12-14
      • 2011-06-12
      相关资源
      最近更新 更多