I want to draw a text to a paint. How to draw it with a custom font (ex Helvetica ) and bold also? I would preffer to use a system font and not create it from assets. Thanks.
相关问题
- 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?
相关文章
- C#中 public virtual string Category { get; }这么写会报错:
- 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
Use this for paint class:
If by "custom font" you mean a font that you are supplying as an asset, the following code should work:
If you want to use a font from resources (Kotlin):
This might not be related to the question, but this is what I was looking for - maybe somebody would need it too.
If you are using Android's new Fonts in XML for your fonts, then to get the typeface used for paint you can use:
or if your min Android API >= 26
Then to apply it to your paint object:
For more info check out https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml#fonts-in-code
If you already have a font in use and want to use a bold version of that you can do this.
I used the answer above, but this modification was necessary for me - so just thought I'd mention it