In my Android app i want to show a view on top of any Activity and still have the focus on the activity. I actually figured this out using a Dialog
with the code bellow:
Dialog progressDialog = new Dialog(getThisContext());
progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
progressDialog.setContentView(R.layout.hint_view_layout);
TextView theText = (TextView) progressDialog.findViewById(R.id.hintText);
theText.setText("(Some Text)");
Window window = progressDialog.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.setGravity(Gravity.BOTTOM);
progressDialog.show();
but the problem is that my view is showing as the following:
But the preview of my xml for the Dialog
is like:
So, with the code above i was able to not dim the background and to keep the focus with the main activity, but how can i make the Dialog
appear in the app just like in the xml preview? Because besides the Dialog
background, its not exactly in the bottom of the view.
Also, how would i add a onTouchListener
to the dialog so the user could could just click to dismiss it?
As a bonus, how would i animate the Dialog
to appear from the bottom up?
Thanks, Newton
Edit #1:
Using the flag FLAG_NOT_TOUCH_MODAL may cause some problems when showing the Dialog in a ListView, so change it to FLAG_NOT_FOCUSABLE instead.