I have found how to create a translucent background for my android app, but so far I haven\'t found how to interact with what\'s behind it (the home screen for example).
FLAG_NOT_TOUCH_MODAL will do what you want with the least code.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
...
setContentView(R.layout.my_activity_view);
...
}
public static final int FLAG_NOT_TOUCH_MODAL
Window flag: Even when this window is focusable (its {@link FLAG_NOT_FOCUSABLE is not set), allow any pointer events outside of the window to be sent to the windows behind it. Otherwise it will consume all pointer events itself, regardless of whether they are inside of the window.
I got the answer.
Adding line getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
in onCreate in second top activity(which is transparent did the trick).
Above solution has a problem. After using above whole window passes the touch to background. So if you want full control then better extend a layout e.g. Framelayout and override 'onTouchEvent' and get the touch location using event.getX() and event.getY() methods and return false where you want to pass the touch event. It will be passed to parent view.
A very simple way of understanding stacking of views is to take a book (any book). Think of each page as a view.
Visibility
VISIBLE
)INVISIBLE
- Main View to show the next view. Remember you are only hiding the view, if you set the visibility to GONE
this is equivalent to tearing of the current page to view the next page.)Touch scenarios
Don't be disheartened, since it is a view you will be dealing with and not a paper you can still do what you want to do :)
View.OnTouchListener
for both your viewsFALSE
in the method onTouch