当我们在窗口管理器中添加视图时,应启用外侧触摸,但在我的情况下,当我在窗口管理器中添加视图时,外部触摸禁用。
WindowManager.LayoutParams params;
params = new WindowManager.LayoutParams();
params.flags =
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
;
params.format = PixelFormat.RGBA_8888;
params.gravity = Gravity.CENTER;
params.type = WindowManager.LayoutParams.TYPE_TOAST;
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.shagun_notify,null);
wm.addView(view, params);
答案 0 :(得分:0)
我尝试了它的工作,你可以试试这个。必须在mainifests.xml中取得权限<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams dialogParams = new
WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
View activityView = inflater.inflate(R.layout.bottom, null);
wm.addView(activityView, dialogParams);
bottom.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="11dp" />
</RelativeLayout>