Android TabLayout 主题色设置指南
<com.google.android.material.tabs.TabLayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabTextColor="@color/tab_unselected_color" app:tabSelectedTextColor="@color/tab_selected_color" />
在 Android 开发中,TabLayout 是一个常用的组件,用于创建标签页。我们可以通过设置 app:tabTextColor 和 app:tabSelectedTextColor 属性来设置 TabLayout 的主题色。这两个属性分别表示 Tab 未选中时的文本颜色和 Tab 选中时的文本颜色。
例如,以下代码展示了如何设置 TabLayout 的主题色:
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextColor="@color/tab_unselected_color"
app:tabSelectedTextColor="@color/tab_selected_color" />
在这个例子中,我们设置了未选中 Tab 的文本颜色为 tab_unselected_color,选中 Tab 的文本颜色为 tab_selected_color。你可以根据自己的需求修改这两个属性的值来设置主题色。
原文地址: https://www.cveoy.top/t/topic/oV86 著作权归作者所有。请勿转载和采集!