我有这样的custom dialog
内Activty
这是内部ActivityGroup
。
我想点击外表面时,关闭对话框,并试图一切,我在网上找到,使其工作..
我已经试过setCanceledOnTouchOutside(true)
-没有工作
我试过了:
public boolean onTouchEvent ( MotionEvent event ) {
// I only care if the event is an UP action
if ( event.getAction () == MotionEvent.ACTION_UP ) {
// create a rect for storing the window rect
Rect r = new Rect ( 0, 0, 0, 0 );
// retrieve the windows rect
this.getWindow ().getDecorView ().getHitRect ( r );
Log.i(r.toShortString(),r.toShortString());
// check if the event position is inside the window rect
boolean intersects = r.contains ( (int) event.getX (), (int) event.getY () );
// if the event is not inside then we can close the activity
if ( !intersects ) {
// close the activity
this.dismiss ();
// notify that we consumed this event
return true;
}
}
并没有太多工作..
正如我在logcat中看到-我认为,从某些原因,对话窗口大小是完全屏蔽就是为什么我没有“外部”接触..
我想可能有做的活动组..任何建议的东西吗?