如何设置吐司的字体?
问题描述:
我能够自定义字体设置为我的文字观点这样如何设置吐司的字体?
Typeface typeface = Typeface.createFromAsset(context.getAssets(),"fonts/akshar.ttf");
setTypeface(typeface);
如何设置同样的事情为默认吐司,使我能够呈现敬酒的消息我的语言环境的文本。我可以设置重力,持续时间但不是字体。
在此先感谢。
答
您可以创建一个自定义的吐司为:
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
OO ...将字体设置为自定义Toast中的文本视图,解决了我的问题。非常简单的事情 – vrs