Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font not getting applied to PopupMenus or the BottomNavigationView #47

Open
AlejandroHCruz opened this issue Nov 29, 2019 · 5 comments
Open

Comments

@AlejandroHCruz
Copy link

Hi, I'm currently experiencing an issue in which the font I've setup to be used everywhere in the app is not working for the PopupMenus or the BottomNavigationView.

I've also tried specifying the fontPath in the items.xml files but it didn't help.

Any ideas?

Thank you!

@yallam08
Copy link

I have the same issue, did you find a solution?

@yallam08
Copy link

yallam08 commented Jan 25, 2020

Hi @AlejandroHCruz, I found a solution for this:
For fixing the popups font, I put the ViewPump initialization code in my BaseActivity's onCreate() so it applies to all my activities:

public abstract class BaseActivity extends AppCompatActivity {

    //.............

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        // apply the default font
        ViewPump.init(ViewPump.builder()
                .addInterceptor(new CalligraphyInterceptor(
                        new CalligraphyConfig.Builder()
                                .setDefaultFontPath(getString(R.string.font_normal))
                                .setFontAttrId(R.attr.fontPath)
                                .build()))
                .build());

        super.onCreate(savedInstanceState);
    }

    //.............

}

And for applying the font on BottomNavigationView, I applied it manually using a recursive function that can actually be used with any view that you want to apply font to all of its TexView child views:

fun applyFont(view: View) {
    if (view is TextView) {
        CalligraphyUtils.applyFontToTextView(context, view, getString(R.string.font_normal))
    }
    if (view is ViewGroup) {
        for (i in 0 until view.childCount) {
            applyFont(view.getChildAt(i))
        }
    }
}

@AlejandroHCruz
Copy link
Author

Very interesting! Thanks a lot @yallam08

@Stevemaster92
Copy link

NavigationView for the navigation drawer has a similar issue #50. I provided the workaround here which is applicable to the BottomNavigationView as well. Just use itemTextAppearanceActive in addition or instead of itemTextAppearance, depending on your needs.

@chrisjenx
Copy link
Member

See answer here: #50 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants