1

Всем привет. Как можно сменить (а можно ли) шрифт текста в TabLayout и TabItem в Android приложении?

введите сюда описание изображения

0

1 ответ 1

0

Сменить шрифт у табов можно так:

public static void changeTabsFont(Context context, TabLayout tabLayout, int color) {

    ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
    tabLayout.setBackgroundColor(color);
    int tabsCount = vg.getChildCount();
    for (int j = 0; j < tabsCount; j++) {
        ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
        int tabChildsCount = vgTab.getChildCount();
        for (int i = 0; i < tabChildsCount; i++) {
            View tabViewChild = vgTab.getChildAt(i);
            if (tabViewChild instanceof TextView) {
                ((TextView) tabViewChild).setTypeface(Typeface.createFromAsset(context.getAssets(), "YoursAwersomeFont.ttf"));
            }
        }
    }
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.