Calligraphy
Calligraphy copied to clipboard
Font not getting applied to PopupMenus or the BottomNavigationView
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!
I have the same issue, did you find a solution?
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))
}
}
}
Very interesting! Thanks a lot @yallam08
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.
See answer here: https://github.com/InflationX/Calligraphy/issues/50#issuecomment-782143750