AppCompat toolbar title font is not set
See original GitHub issueHi! I am trying to style toolbar font, but nothing happens. I am able to set font color and style, but not the font itself. I am using the latest calligraphy (2.2.0), appcompat (23.4.0), Android 6.0.
<android.support.v7.widget.Toolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:title="@string/app_name"
app:titleTextAppearance="@style/DancingWhite"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"/>
...
<style name="DancingWhite" parent="android:TextAppearance">
<item name="android:textSize">22sp</item>
<item name="android:textColor">@color/colorTitle</item>
<item name="android:textStyle">italic</item>
<item name="fontPath">fonts/DancingScript-Regular.otf</item>
</style>
Issue Analytics
- State:
- Created 7 years ago
- Comments:23 (2 by maintainers)
Top Results From Across the Web
How to set a custom font to the title in toolbar android
Select the option of fontFamily and select the font you want under the given options. If it is not given, you can search...
Read more >How to Change Font of Toolbar Title in an Android App?
First, add a font file in the src/main/assets/fonts/ of your project. Then create variables for Toolbar and text title and call the method ......
Read more >Change Toolbar Font-Family in Android. | by Danish Amjad
Change Font for Toolbar. Now, In Android, we often need to change the font-family for Toolbar as well to look more appealing UI...
Read more >Toolbar - Android Developers
Toolbar supports a more focused feature set than ActionBar. ... android:accessibilityHeading, Whether or not this view is a heading for accessibility ...
Read more >Android Appcompat Toolbar Title Not Shown Correctly
This page shows Java code examples of androidx.appcompat.widget. Sets the font of any TextView found within the ToolBar. when this issue gets resolved:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem is that Toolbar creates TextViews for title and subtitle programmatically inside itself. It means that it doesn’t use wrapped LayoutInflater by Calligraphy. Instead it uses system Typefaces depending on fontFamily and fontStyle from textAppearence attribute.
But Calligraphy listens for GlobalLayout changes and tries to load style from theme.
So what I’ve done: Add activity theme and customize ActionBarStyle:
+1 here: using calligraphy:2.2.0, appcompat-v7:25.1.1
Everything is set on the toolbar title from the style (color, size) except the font. And I added the attachBaseContext override in the activity.