Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. public static void changeTabsFont(Context context, TabLayout tabLayout, int color) {
  2.  
  3.     ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
  4.     tabLayout.setBackgroundColor(color);
  5.     int tabsCount = vg.getChildCount();
  6.     for (int j = 0; j < tabsCount; j++) {
  7.         ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
  8.         int tabChildsCount = vgTab.getChildCount();
  9.         for (int i = 0; i < tabChildsCount; i++) {
  10.             View tabViewChild = vgTab.getChildAt(i);
  11.             if (tabViewChild instanceof TextView) {
  12.                 ((TextView) tabViewChild).setTypeface(Typeface.createFromAsset(context.getAssets(), "Lato-Regular.ttf"));
  13.             }
  14.         }
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement