I used a layer of framelayout with a semi-translucent background to create an overlay. But this overlay doesn\'t block touch events to interact with the views below it. How sho
Following code will add overlay on top of everything :
View v1 = new View(this);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
1000,
50,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.OPAQUE);
params.gravity = Gravity.BOTTOM;
WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
wm.addView(v1, params);
to block the touch event either you have to change the flag or below code will work:
protected boolean onTouchEvent (MotionEvent me) {
return true;
}
For v1 you would do an import:
import android.view.View.OnTouchListener;
Then set the onTouchListener:
v1.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
})