'Is there a way to set different fontFamily to each tab items in TabLayout?
So I am working with com.google.android.material.tabs.TabLayout
And using a particular fontFamily on it. But what I wanted to develop is
Giving a separate fontFamily to selected Tab and different to unselected Tab. like roboto_medium and roboto_light
Below is how I am using my tabTextAppearance
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutForgot"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_height"
android:layout_marginTop="@dimen/header_height"
app:layout_constraintTop_toBottomOf="@+id/imageViewLogo"
app:tabGravity="fill"
app:tabIndicatorColor="@color/black_blue"
app:tabIndicatorFullWidth="false"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/text_color"
app:tabTextAppearance="@style/MyCustomTabLayout"
app:tabTextColor="@color/text_color" />
and the styles that I have added in tabTextAppearance are as below
<style name="MyCustomTabLayout" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item>
<item name="android:textSize">@dimen/design_tab_text_size_2line</item>
<item name="android:fontFamily">@font/roboto_medium</item>
<item name="android:textColor">@color/text_color</item>
</style>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
