如何设置敬酒字样? [英] how to set typeface for toast?
本文介绍了如何设置敬酒字样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我能字体设置自定义像这样我的文本视图
I am able to set custom font to my text view like this
Typeface typeface = Typeface.createFromAsset(context.getAssets(),"fonts/akshar.ttf");
setTypeface(typeface);
如何设置同样的事情为默认吐司使我能够呈现敬酒的消息我的语言环境的文本。我能设置重力,持续时间但不字样。
How can I set same thing to default Toast so that I am able to render my locale text in toast messages. I am able to set Gravity, duration but not typeface.
先谢谢了。
推荐答案
您可以创建一个自定义吐司为:
YOu can Create a custom Toast as:
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout,
(ViewGroup) findViewById(R.id.toast_layout_root));
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello! This is a custom toast!");
Typeface typeface = Typeface.createFromAsset(context.getAssets(),"fonts/akshar.ttf");
text.setTypeface(typeface);
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
和更多的细节,我们如何创建一个自定义吐司看到 CustomToastView
and for more details how we create a custom Toast see CustomToastView
这篇关于如何设置敬酒字样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文