How to change the font in a TextView
, as default it's shown up as Arial? How to change it to Helvetica
?
相关问题
- 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
Best practice ever
TextViewPlus.java:
attrs.xml: (Where to place res/values)
How to use:
Hope this will help you.
get font from asset and set to all children
When your font is stored inside
res/asset/fonts/Helvetica.ttf
use the following:Or, if your font file is stores inside
res/font/helvetica.ttf
use the following:This way, you can create a View which inherits from TextView and calls setTypeface on its constructor.
First, the default is not Arial. The default is Droid Sans.
Second, to change to a different built-in font, use
android:typeface
in layout XML orsetTypeface()
in Java.Third, there is no Helvetica font in Android. The built-in choices are Droid Sans (
sans
), Droid Sans Mono (monospace
), and Droid Serif (serif
). While you can bundle your own fonts with your application and use them viasetTypeface()
, bear in mind that font files are big and, in some cases, require licensing agreements (e.g., Helvetica, a Linotype font).EDIT
After ICS, android includes Roboto fonts style, Read more Roboto
EDIT 2