I'm creating an activity that looks like a dialog.
Here is the style:
<style name="TablesDialogActivity" parent="@android:style/Theme.Holo.Dialog">
<item name="android:windowBackground">@drawable/frame_background_left</item>
</style>
Here is the activity onCreate():
protected void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL, LayoutParams.FLAG_NOT_TOUCH_MODAL);
getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
super.onCreate(savedInstanceState);
}
And also inside the activity touch interceptor:
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
finish();
return true;
}
return false;
}
It pretty much works, activity finishes on touch outside dialog bounds, but it also interacts with buttons on the background activity which is bad. Documentation on the onTouchEvent
says that you should return true if you consumed the touch event. I return true, but it doesn't seem that way.