我想更改android中的字体和样式。这该怎么做?我正在使用模拟器。这可能会在模拟器中更改。是否有任何权限可以做到这一点。提前致谢。
答案 0 :(得分:26)
字体
Typeface.DEFAULT
Typeface.MONOSPACE
Typeface.SANS_SERIF
Typeface.DEFAULT_BOLD
Typeface.SERIF
和font-type
Typeface.NORMAL
Typeface.BOLD
Typeface.BOLD_ITALIC
Typeface.ITALIC
你可以像
一样使用textView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
和其他方式是download any .ttf file
并将其放在资产文件夹中并像这样使用
Typeface type=Typeface.createFromAsset(context.getAssets(),
"DroidSansMono.ttf");
textView.setTypeface(type, null);
答案 1 :(得分:4)
您可以更改XML文件中的字体样式和字体。例如,如果您想要更改Button的样式和面部。在xml中选择您的按钮,然后按照以下方法:
Button -> Right Click -> Properties -> Typeface and style
希望这会对你有所帮助。
答案 2 :(得分:3)
答案 3 :(得分:2)
Typeface type = Typeface.createFromAsset(this.getAssets(),"your font name");
text.setTypeface(type);
对于样式,请使用以下链接:
答案 4 :(得分:1)
如果您想在Android应用程序中使用非默认字体(如“Helvetica”),请将字体文件(Helvetic.ttf)放在assets文件夹中,并使用以下代码:
Typeface tf= Typeface.createFromAsset(getAssets(), "Helvetica.ttf");
TextView mTextView =(TextView) findViewById(R.id.text);
mTextView.setTypeface(tf);
答案 5 :(得分:1)
如果你想使用自定义字体jus下载.ttf文件并将文件放入assets文件夹 并使用这样:
TextView tv=(TextView)findViewById(R.id.textView);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/arial.ttf");
tv.setTypeface(tf);