Toast工具,解决连续弹出toast以及toast不能全屏的问题
2014-04-23 14:17
253 查看
public class ToastUtil { private static final String TAG = ToastUtil.class.getSimpleName(); private ToastUtil() {} private static Toast mToast = null; public static final void showToast(Context context, String content) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.toast, null); TextView textview = (TextView) view.findViewById(R.id.toast_content); if (!TextUtils.isEmpty(content)) { textview.setText(content); } if (mToast == null) { mToast = new Toast(context); mToast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.TOP, 0, 0); mToast.setDuration(Toast.LENGTH_SHORT); } mToast.setView(view); mToast.show(); } }
设置这句
mToast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.TOP, 0, 0);
就可以全屏了。
相关文章推荐
- android实用小工具:只弹一次的toast,解决toast重复弹出的问题。
- 问题系列:解决Dialog全屏显示以及Dialog显示自动弹出输入法(转)
- 打造全局Dialog,Toast,解决Toast多次弹出以及小米无法弹出悬浮窗问题
- 自定义AlertDialog,以及解决自定义Dialog中EditText不能弹出输入法的问题
- android 软键盘不能弹出 问题解决
- 解决Android平板电脑上开发应用程序不能全屏显示的问题
- 解决Python自带的json序列化工具不能序列化datetime类型数据问题
- 如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题
- ListView里面有EditTextView,解决弹出键盘后EditView不能获取焦点的问题
- 怎样解决Java Web项目更改项目名后报错以及不能找到web路径问题
- AlertDialog实现自定义布局以及解决EditText无法弹出软键盘或者软键盘弹出错误问题
- mac svn升级问题以及CornerStone不能commit问题解决
- Android在thread中Toast不能显示有关问题解决
- Android在thread中Toast不能显示问题解决
- 解决VMware 虚拟机 Ubuntu 不能全屏问题(实测有用)
- seureCRT 快捷键、常用技巧以及 解决不能删除字符问题
- Ubuntu英文环境下解决chrome evernote插件不能切换到中文印象笔记-剪藏以及印象笔记-悦读的问题
- 解决Android关闭通知消息权限无法弹出Toast的问题
- 关于解决DevExpress用DevExpress patch工具破解后经常弹出试用框的问题
- 【system】解决window7/8不能全屏,或者出现黑边的问题