
Typeface typeface = Typeface.createFromAsset(context.getAssets(),"Fonts/akshar.ttf");setTypeface(typeface);
如何将相同的东西设置为默认Toast,以便我能够在Toast消息中呈现我的区域设置文本.我能够设置重力,持续时间而不是字体.
提前致谢.
解决方法 你可以创建一个自定义Toast: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); toast.setDuration(Toast.LENGTH_LONG); toast.setVIEw(layout);toast.show(); 有关我们如何创建自定义Toast的详细信息,请参阅CustomToastView
总结以上是内存溢出为你收集整理的android – 如何为toast设置字体?全部内容,希望文章能够帮你解决android – 如何为toast设置字体?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)