简体   繁体   English

设置标签指示器高度以匹配父/标签高度

[英]Set tab indicator height to match parent/tab height

Is there any way I can set the height of the tab indicator to the tab's height in android?有什么办法可以将标签指示器的高度设置为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"
        />

I am able to do it by hardcoding the layout_height and tabIndicatorHeight to 30dp.我可以通过将 layout_height 和 tabIndicatorHeight 硬编码为 30dp 来实现。 But is it any better way to do it?但是有没有更好的方法来做到这一点? Using wrap_content or something similar.使用 wrap_content 或类似的东西。

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

app:tabIndicatorGravity="stretch"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有雨云的JTabbedPane制表符高度 - JTabbedPane tab height with nimbus 如何设置JTabbedPane选项卡的高度,宽度,背景前景色(选中和未选中的选项卡) - How to set JTabbedPane Tab height width background foreground color (Both selected and Unselected Tab) 无法为Android标签指示器设置图像 - Can not set Image for Tab Indicator Android 如何处理JTabbedPane中标签标题的高度 - How to handle the height of the tab title in JTabbedPane Expandablelistview子视图呈现两次(尽管将高度设置为match_parent) - Expandablelistview Child view rendered twice (inspite of height set to match_parent) 如何设置元素的高度以匹配另一个元素的高度? 在 android - How to set height of element to match height of another element? in android 如何以编程方式调整 android 中选项卡的高度和加粗文本? - How to adjust the height and bold the text of the tab's in android programmatically? 将图标设置为选项卡 - Setting an icon As tab Indicator in tablayout Android Studio:标签指示器处于活动状态 - Android Studio: Tab indicator active 如何在不改变位置的情况下增加 xml 中的标签高度。 viewpager 也落后于选项卡布局 - How to increase tab height in xml without changing position. Also viewpager goes behind tab layout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM