Search code examples
androidandroid-studioandroid-service

Is it possible to add a colored frame/border to the screen as an Android service so, users can navigate through apps while the frame is there?


I want to add a colored frame on the screen as a service so the user can use other apps while the frame is there. Is this possible? For example, the red frame on this image.


Solution

  • Yeah, It is possible. I managed to build such a tool.

    I created a FloatingWindow class which extends Service. Within the FloatingWindow, I created a WindowManager and set it to be full screen.

    I set the WindowManager.LayoutParameters to be FLAG_NOT_TOUCHABLE | FLAG_NOT_FOCUSABLE.

    WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(width, height, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT);
    

    I set the parent layout to be RelativeLayout and transparent. Then I added 4 Children (4 RelativeLayouts filled with the same color: 2 for the columns and 2 for the rows). Here's a screenshot of the tool.