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.

Design Support Library support?

See original GitHub issue

I’ve noticed the fonts in the CollapsingToolbarLayout in particular, the Title attribute, isn’t set. I’ve had to resort to something ugly like the following to get it to set the font on it:

public static void modifyCollapsingToolbarTextFont(Context context, CollapsingToolbarLayout collapsingToolbar) {
        // Hack so that the typeface is correct for the title and the title is centered
        try {
            // Get the mCollapsingTextHelper instance
            Field declaredField = collapsingToolbar.getClass().getDeclaredField("mCollapsingTextHelper");
            Object collapsingTextHelper = declaredField.get(collapsingToolbar);

            // The get its mTextPaint field
            Field paintField = collapsingTextHelper.getClass().getDeclaredField("mTextPaint");
            TextPaint textPaint = (TextPaint) paintField.get(collapsingTextHelper);

            final Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/FrutigerLTStd-Light.otf");

        } catch (Exception e) {
            Timber.e(e, "Unexpected error.");

I’d much rather have Calligraphy handle this for me in a nice, unseen, magical way as per usual. I was hoping that the following would just work:

    <style name="TextAppearance.Hero.Title" parent="TextAppearance.AppCompat.Title">
        <item name="fontPath">fonts/FrutigerLTStd_Light.ttf</item>
        <item name="android:textColor">@color/cpb_text_color_error</item>
        <item name="android:textSize">@dimen/hero_font_size</item>
        <item name="android:textStyle">normal</item>

And then in the layout:


But, sadly, it doesn’t set the font.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

dsardaricommented, Feb 18, 2016

An alternative method for setting the typeface for the CollapsingToolbarLayout for anyone else that was wondering:

chrisjenxcommented, Jan 30, 2017

Yeah sure, it would be better as a plugin, we are working on making this much more flexible at the moment.

On Mon, 30 Jan 2017 at 10:18 Kusand wrote:

Drat. Would that be desirable to patch in? I can probably get some bandwidth to do so, and clearance to contribute.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support Library Packages - Android Developers
The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers, ......
Read more >
Android Design Support Library - Android Developers Blog
The Design library, AppCompat, and all of the Android Support Library are important tools in providing the building blocks needed to build a ......
Read more >
Design Support Library | CodePath Android Cliffnotes
At their I/O 2015 conference, Google announced a new design support library, which helps bring a lot of material design components including a...
Read more >
Import new Android Design Support library - Stack Overflow
Hi i'am trying to import the new android support library like this but i got this error after sync the gradle ...
Read more >
Android Material Design and the Design Support Library
gradle file and add Design Support Library in dependencies section. Sync project. dependencies { compile fileTree(dir: 'libs', include: [' ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found