Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // setTargetSDK = 19
- WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
- Button overlayedButton = new Button(this);
- overlayedButton.setText("Overlay button");
- overlayedButton.setOnTouchListener(this);
- overlayedButton.setAlpha(1);
- overlayedButton.setBackgroundColor(Color.BLACK);
- overlayedButton.setOnClickListener(this);
- WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);
- params.gravity = Gravity.LEFT | Gravity.TOP;
- params.x = 0;
- params.y = 0;
- wm.addView(overlayedButton, params);
- View topLeftView = new View(this);
- WindowManager.LayoutParams topLeftParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);
- topLeftParams.gravity = Gravity.LEFT | Gravity.TOP;
- topLeftParams.x = 0;
- topLeftParams.y = 0;
- topLeftParams.width = 0;
- topLeftParams.height = 0;
- wm.addView(topLeftView, topLeftParams);
Advertisement
Add Comment
Please, Sign In to add comment