我希望在我的应用程序上方拥有一个透明的视图。
我只需要知道当前的活动即可实现这一点。
通过windowManager添加一个新的framelayout,我找到了一种方法来实现这一点。我正在做以下操作:
public static void AddViewAbove(Activity activity) {
FrameLayout newLayout = new FrameLayout(activity);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT,
WindowManager.LayoutParams.TYPE_APPLICATION,
// if I let WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
// then touchevent are passed to the application behind, but I cant handle touch in
// my new frameLayout
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
activity.getWindowManager().addView(newLayout , lp);
}
我的主要问题是在新的FrameLayout中无法正确接收触摸事件,同时在我的视图后面的应用程序中也无法接收。