设置“材质”标签的样式

问题描述 投票:0回答:1

我正在使用Kotlin在我的android应用中处理材料设计。我想知道如何设置标签布局的样式,如下图所示。谢谢!

Tab Layout

 <com.google.android.material.tabs.TabLayout
        android:id="@+id/profileFreelancerTabLayoutCu"
        style="@style/Widget.AppCompat.Light.ActionBar.TabBar"
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        app:tabTextColor="@color/colorPrimary"
        android:layout_marginVertical="20dp"
        android:layout_marginHorizontal="40dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/registeredOnValueProfileFreelancerCu"
        />
android kotlin material-design android-tablayout material-components
1个回答
0
投票

只需使用app:tabIndicatorGravity="stretch"属性来扩展指示器以匹配此布局中选项卡项目的高度和宽度。您也可以使用app:tabIndicatorColor属性设置背景颜色:

  <com.google.android.material.tabs.TabLayout
      app:tabIndicatorGravity="stretch"
      app:tabIndicatorColor="@color/...."
      ...>

enter image description here

删除 style="@style/Widget.AppCompat.Light.ActionBar.TabBar"

© www.soinside.com 2019 - 2024. All rights reserved.