Toast添加动画

WindowManger  wm =(WindowManger)context.getSystemService(Context.WINDOW_SERVICE);

View view = Toast.makeText(context,text,Toast.LENGTH_SHORT).getView();

//设置布局参数
WindowManger.LayoutParams params = new WindowManger.LayoutParams(0;

params.height = WindowManger.LayoutParams.WRAT_CONTENT;

params.width = WindowManger.LayoutParams.WRAT_CONTENT;

params.format = PixelFormat.TRANSLUCENT;

//设置进入退出动画效果
params.windowAnimations = R.style.anim_view;
params.type = WindowManger.LayoutParams.TYPE_TOAST;
params.flags = WindowManger.LayoutParams.FLAG_KEEP_SCREEN_ON|WindowManger.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManger.LayoutParams.FLAG_NOT_TOUCHABLE;
params.gravity = Gravity.CENTER_HORIZONTAL:
params.y = 250;

//显示
wm.addView(view,params);

//一段时间后隐藏,一段时间后调用
wm.removeView(view);

  

posted @ 2016-04-12 21:38  狂奔的小狮子  阅读(933)  评论(0编辑  收藏  举报