关于Android WindowManager显示悬浮窗的动画效果
要实现WindowManager添加的窗口,实现动画显示,就需要添加如下红色的属性,其他的添加View只要设置其Animations属性也会实现动画,当然自己实现也可,但是能直接用系统的已经实现好的,也很方便。
windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
WindowParams = new LayoutParams(LayoutParams.FLAG_FULLSCREEN,LayoutParams.FLAG_FULLSCREEN);
WindowParams.type=LayoutParams.TYPE_SYSTEM_ERROR;
WindowParams.flags=LayoutParams.FLAG_ALT_FOCUSABLE_IM; //window gets focus
WindowParams.format=PixelFormat.TRANSPARENT; //set the opacity to 100%
WindowParams.windowAnimations=android.R.style.Animation_Translucent; // set the animation for the window
WindowParams.gravity = Gravity.RIGHT | Gravity.TOP;
windowManager.addView(view, WindowParams);