How to Set a Custom Font in the ActionBar Title?

后端 未结 17 1743
面向向阳花
面向向阳花 2020-11-22 09:46

How (if possible) could I set a custom font in a ActionBar title text(only - not the tab text) with a font in my assets folder? I don\'t want to use the android:logo option.

17条回答
  •  旧巷少年郎
    2020-11-22 10:17

    From Android Support Library v26 + Android Studio 3.0 onwards, this process has become easy as a flick!!

    Follow these steps to change the font of Toolbar Title:

    1. Read Downloadable Fonts & select any font from the list (my recommendation) or load a custom font to res > font as per Fonts in XML
    2. In res > values > styles, paste the following (use your imagination here!)

      
      
    3. Insert a new line in your Toolbar properties app:titleTextAppearance="@style/TextAppearance.TabsFont" as shown below

      
      
    4. Enjoy Custom Actionbar Title font styling!!

提交回复
热议问题