简体   繁体   English

使选项卡布局指示器小于选项卡标题

[英]Make Tab Layout Indicator smaller than the tab title

Make small indicator for tab layout tabs.为选项卡布局选项卡制作小指示器。 I have tried with tabIndicatorFullWidth but it only wraps up with the title of tab, I want to make it more smaller.我已经尝试使用 tabIndicatorFullWidth 但它只包含选项卡的标题,我想让它更小。

Example Image:示例图像: 例子

You can use custom indicator drawable for small indicator tabs.您可以将自定义指标 drawable 用于小型指标选项卡。

like this>>像这样>>

tab_layout_indicator.xml tab_layout_indicator.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:width="20dp"
        android:height="5dp"
        android:gravity="center">
        <shape android:shape="rectangle">
            <corners android:radius="5dp"/>
            <solid android:color="@color/green"></solid>
             
        </shape>
    </item>
</layer-list>

And Use this indicator to your xml layout file.并将此指标用于您的 xml 布局文件。

<com.google.android.material.tabs.TabLayout
                        android:id="@+id/tabs"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        app:tabIndicator="@drawable/tab_layout_indicator"
                        app:tabGravity="fill"
                        app:tabMode="scrollable"        
                      ></com.google.android.material.tabs.TabLayout>

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

相关问题 Android 选项卡布局:根据选项卡标题换行选项卡指示器宽度 - Android Tab layout: Wrap tab indicator width with respect to tab title 带有自定义指示器的选项卡布局 - Tab layout with custom indicator Android 选项卡布局:无论标题内容如何,始终将选项卡指示器宽度包装为 4dp - Android Tab layout: Wrap tab indicator width to 4dp always irrespective of title content 将颜色设置为选项卡布局中未选中的选项卡指示器 - Set color to unselected tab indicator in tab layout 如何在操作栏中移动标题标签指示器? - How to Move Title Tab Indicator in Action bar? Android 带圆角的材料选项卡布局指示器 - Android Material Tab Layout indicator with round corners 我们如何在“jetpack compose”中将选项卡布局的“选项卡指示器”移动到顶部? 默认情况下,它显示在选定选项卡的底部 - How can we move "tab indicator" of Tab layout to top in "jetpack compose"? By default it is appearing at bottom of selected tab 如何使用选项卡布局设置标题 - how to set the title using tab layout 具有 3 个以上项目的 BottomNavigationView:选项卡标题正在隐藏 - BottomNavigationView with more than 3 Items: tab title is hiding 标签指示器中的字体颜色 - Font color in tab indicator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM