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);
时刻怀有一颗虔诚之心,乐于分享。知识才更有意义。