Out side touch should be enable when we add view in window manager

空扰寡人 提交于 2019-12-24 19:41:31

问题


Out side touch should be enable when we add view in window manager but in my case outside touch disable when i add view in window manager.

    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);

回答1:


I tried this its working you can try this .must take the permission <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> in mainifests.xml

        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>


来源:https://stackoverflow.com/questions/48089783/out-side-touch-should-be-enable-when-we-add-view-in-window-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!