2

I have created a custom style for my tab layout in styles.xml file.

styles.xml

<style name="NormalTabLayputTheme" parent="ThemeOverlay.AppCompat.Light">
    <item name="tabTextAppearance">@style/NormalTabLayputTheme</item>
</style>

<style name="NormalTabTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">14sp</item>
    <item name="textAllCaps">false</item>
</style>

I am able to use the style in my layout file as;

<android.support.design.widget.TabLayout
    android:id="@+id/marketsTabs"
    style="@style/NormalTabLayputTheme"
    android:layout_width="match_parent"
    android:layout_height="@dimen/dashboard_viewpager_tab_height"
    app:paddingStart="1dp"
    app:tabIndicatorHeight="3dp"
    app:tabIndicatorColor="@color/view_pager_indicator_color"
    app:tabSelectedTextColor="@color/nintypercentblack"
    app:tabTextColor="@color/sixtypercentblack">

Everything works fine. But I want to change the style at runtime. I have gone through stackoverflow, but haven't found anything about this. Is it possible ?

I have tried making a CustomTabLayout class extending TabLayout, no success either.

Nayan
  • 367
  • 4
  • 18
  • 1
    Try this: https://stackoverflow.com/questions/26820452/add-style-after-creating-a-view-programmatically – InfZero Jul 22 '17 at 16:48

0 Answers0