android custom font for tabs

半城伤御伤魂 提交于 2019-12-06 00:10:01

The only (currently) available way to set Fonts is to do it programatically:

TextView tv= (TextView)findViewById(R.id.custom);
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/heartbre.ttf");
tv.setTypeface(face);

However, I hope there will be a xml-way to do it some day!

Gabriel Sanmartin

You can only define custom fonts by code or through styleable attributes in a custom object extending TexView like here

No possibility to add manually from XML (as far as I know!). You have to do it within your code:

Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/heartbre.ttf");
textView.setTypeface(typeface, Typeface.BOLD);
Munim Dibosh

Please refer to this question setting custom font for sherlock action bar tab android and check my answer. So far the solution I posted there is the best working one in all cases. Hope it will help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!