question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

not supported in 'tabTextAppearance' attribute in TabLayout

See original GitHub issue

Want to use with tabTextAppearance attribute

like this:

in styles:

    <style name="TextAppearance.RobotoMedium" parent="android:TextAppearance">
        <!-- Custom Attr-->
        <item name="fontPath">fonts/Roboto-Medium.ttf</item>
    </style>

in layout:

 <android.support.design.widget.TabLayout
               ...
               ...
               app:tabTextAppearance="@style/TextAppearance.RobotoMedium"
 />

don’t want to to this: ##http://stackoverflow.com/a/39252162/1529129

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

3reactions
xeon90commented, Apr 22, 2017

I just found why, because Tab is added after calligraphy injected and apply font, and not sure TabLayout not referencing the typeface when adding Tab If your tab is added dynamically like my case, this is the only solution i have, you can refer my code, it is improved and cleaner version from your link, applicable for activity, but dynamic view like recycler view need to apply for the newly added view.

Picture for your reference, u can see the 3rd tab is not apply typeface after i call apply root view

    protected void apply(ViewGroup vg)
    {
        Typeface type = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/oxygen_light.ttf");

        for(int i = 0; i < vg.getChildCount(); ++i)
        {
            View v = vg.getChildAt(i);
            if(v instanceof TextView)
                ((TextView) v).setTypeface(type);
            else if(v instanceof ViewGroup)
                apply((ViewGroup) v);
        }
    }

You can do this in activity root view

    setContentView(R.layout.activity_main);
    apply((ViewGroup) findViewById(android.R.id.content));

screenshot_20170422-231059

0reactions
dfavarocommented, Jun 7, 2019

Hi, issue still present. Any solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

android:textAllCaps="false" not working for TabLayout design ...
We have to use 'app:tabTextAppearance' atrribute instead of 'style' attribute. – thilina Kj. Oct 4, 2017 at 20:03. 1.
Read more >
TabLayout | Android Developers
Returns whether tab labels will be displayed inline with tab icons, or if they will be displayed underneath tab icons. boolean ...
Read more >
Google Play Style Tabs using TabLayout - CodePath Cliffnotes
TabLayout , which will be used for rendering the different tab options. ... You can override this behavior by changing the tabTextAppearance property....
Read more >
All-in-One — Android TabLayout and TabItem | by Myrick Chow
TabLayout is a common widget working with ViewPager and ViewPager2. ... It is not recommended to use this attribute unless you clearly understand...
Read more >
ViewPager2 and TabLayout Android - Narayan Panthi - Medium
Tab Indicator. We can customize the tab indicators with attributes like. app:tabIndicator="@drawable/custom_tab_indicator" app:tabIndicatorColor ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found