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.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I agree that this isn't completely supported, but here's what I did. You can use a custom view for your action bar (it will display between your icon and your action items). I'm using a custom view and I have the native title disabled. All of my activities inherit from a single activity, which has this code in onCreate:
And my layout xml (R.layout.titleview in the code above) looks like this:
To add to @Sam_D's answer, I had to do this to make it work:
It seems like overkill - referencing v.findViewById(R.id.title)) twice - but that's the only way it would let me do it.
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:
res > font
as per Fonts in XMLIn
res > values > styles
, paste the following (use your imagination here!)Insert a new line in your Toolbar properties
app:titleTextAppearance="@style/TextAppearance.TabsFont"
as shown belowEnjoy Custom Actionbar Title font styling!!
No custom textview is required!
First, disable the title in the toobar in your java code : getSupportActionBar().setDisplayShowTitleEnabled(false);
Then, simply add a TextView inside the toolbar :
We need to use reflections for achieving this
TRY THIS