android - Dialogue Like Activity is not Finishing on touch outside -
i created activity looks dialog .this did achieve
requestwindowfeature(window.feature_no_title); display display = getwindow().getwindowmanager().getdefaultdisplay(); layoutparams params = getwindow().getattributes(); params.height = (display.getheight()*3)/4; params.width = (display.getwidth()) / 2; params.alpha = 1.0f; params.dimamount = 0.5f; params.gravity=gravity.top | gravity.right;; getwindow().setattributes((android.view.windowmanager.layoutparams) params); setcontentview(r.layout.search_activity); linearlayout layout = (linearlayout)findviewbyid(r.id.root); linearlayout.layoutparams lp = new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.match_parent); lp.setmargins(0, getintent().getextras().getint("height"), 0, 0); layout.setlayoutparams(lp);
style used create this
<style name="popuptheme" parent="android:theme.holo.light.dialog"> <item name="android:windowisfloating">false</item> <item name="android:windowcontentoverlay">@null</item> <item name="android:windowsoftinputmode">statealwayshidden</item> <item name="android:windowactionmodeoverlay">true</item> <item name="android:windowistranslucent">true</item> <item name="android:windowcloseontouchoutside">true</item> <item name="android:windowbackground">@android:color/transparent</item> </style>
and obtained: blue area activity .actually wen touch out side activity activity must gone view. it's working .but activity not getting finished .i want finish when touch it
i tried this.setfinishontouchoutside(true);
and
@override public boolean ontouchevent(motionevent event) { // if we've received touch notification user has touched // outside app, finish activity. if (motionevent.action_outside == event.getaction()) { finish(); return true; } // delegate else activity. return super.ontouchevent(event); }
i know line <item name="android:windowcloseontouchoutside">true</item>
helps close activity view .but there way access attribute programmatically . didn't me .can tell me how can achieve it??
try
public void onpause(){ super.onpause(); finish(); }
Comments
Post a Comment