Dialog class
1 Public classDialogutil {2 3 Public StaticDialog editdialog (Activity context,view View) {4 FinalDialog Dialog =NewDialog (context, r.style.dialogstyle);5 Dialog.setcontentview (view);6window window =Dialog.getwindow ();7Windowmanager.layoutparams LP =window.getattributes ();8 intScreenWidth =getscreenwidth (context);9Lp.width =ScreenWidth;Ten window.setgravity (gravity.center); One returnDialog; A - } - the Public Static intGetscreenwidth (Activity context) { -Displaymetrics DM =Newdisplaymetrics (); - Context.getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); - returnDm.widthpixels; + } - + Public Static intGetscreenheight (Activity context) { ADisplaymetrics DM =Newdisplaymetrics (); at Context.getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); - returnDm.heightpixels; - } - -}
Style
1 2<style name= "Dialogstyle" >3<item name= "Android:windowbackground" > @android:color/transparent</item>4<item name= "Android:windownotitle" >true</item>5<item name= "Android:windowistranslucent" >true</item>6<item name= "Android:windowcontentoverlay" >@NULL</item>7<item name= "Android:windowfullscreen" >false</item>8<item name= "Android:windowisfloating" >true</item>9</style>
Call:
PrivateDialog Meditnamedialog; Private voidShoweditdialog () {if(Meditnamedialog = =NULL) {View v= Layoutinflater.from ( This). Inflate (R.layout.dialog_meeting_detailed_edit_name,NULL); Meditnamedialog= Dialogutil.meetingdetailededitname ( This, V); Meditnamedialog.show (); }Else{ if(Meditnamedialog.isshowing ()) Meditnamedialog.dismiss (); Elsemeditnamedialog.show (); } }
. xml;
android Dialog Instances