Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are different approaches to displaying an Android view outside of the layout, depending on the context and purpose of the view. Here are some potential options:

  1. Create a floating view: This involves creating a new view that can be positioned outside of the layout, and adding it to the WindowManager using the WindowManager.LayoutParams.FLAGNOTFOCUSABLE and WindowManager.LayoutParams.FLAGNOTTOUCH_MODAL flags. This will allow the view to float over other views and receive touch events, without interfering with the underlying layout.

  2. Use a transparent activity/window: Another approach is to create a transparent activity or window, which can be positioned outside of the main layout bounds. This could be useful for displaying information that should be visible at all times, but not interfere with the main UI.

  3. Overlay view on top of app: You can use an Overlay view to display a view on top of the current app. The Overlay view can be positioned anywhere, roughly equivalent to floating views.

  4. Use WindowManager: You can use the WindowManager service to add a view programmatically outside of the layout.

It's worth noting that some of these approaches may have implications for the user experience or functionality of the app, so it's important to consider the context and use case carefully before implementing them.