Toast添加动画

简介: WindowManger wm =(WindowManger)context.getSystemService(Context.WINDOW_SERVICE); View view = 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);

  

目录
相关文章
RecyclerView 添加动画
RecyclerView 添加动画
196 0
|
Java Android开发 索引
使用LayoutAnimationController为RecyclerView添加动画
### 使用LayoutAnimationController为RecyclerView添加动画 @author:莫川 #### 一、前言 为RecyclerView的Item添加动画有很多中方案,比如通过[设置setItemAnimator来实现](https://github.com/wasabeef/recyclerview-animators)或者是[通过遍历Recycler
4842 0
RecyclerView的下拉刷新和加载更多 动画
下拉刷新和加载更多 1、https://github.com/jianghejie/XRecyclerView 2、http://blog.csdn.net/jabony/article/details/44780187   动画 1、https://github.
1947 0