type :
WindowManager.LayoutParams.TYPE_TOAST
flag:
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
代码:
if (mVolumeView == null) {
WindowManager mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
View rootView = View.inflate(context, R.layout.volume_layout, null);
mVolumeView = (VolumeView) rootView.findViewById(R.id.volume);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_TOAST,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
layoutParams.gravity = Gravity.TOP;
mWindowManager.addView(rootView, layoutParams);
}