Public voidShow (view view) {Mydialog Mydialog=NewMydialog (mainactivity. This); Mydialog.show ();//you need to set the property, otherwise the size of the dialog does not work! must first show again set propertyWindowmanager.layoutparams params =Mydialog.getwindow (). GetAttributes (); Params.width= 600; Params.height= 300; View View1= View.inflate (Getapplicationcontext (), R.layout.dialogview,NULL);//set the properties of a locationWindow Dialogwindow =Mydialog.getwindow ();//windowmanager.layoutparams LP = Dialogwindow.getattributes ();Dialogwindow.setgravity (Gravity.left |gravity.top); //You must use this method, you cannot use the method of Dialog.setview ()Mydialog.getwindow (). Setcontentview (R.layout.dialogview); Dialogwindow.setattributes (params); }
--------------------------------------------------------------------------------------------------------------- -------
public class Mydialog extends Dialog {
Public Mydialog (Context context) {
Super (Context,r.style.sharedialog);
}
}
--------------------------------------------------------------------------------------------------------------- ----------
<style name= "Sharedialog" parent= "Android:Theme.Dialog" >
<item name= "Android:windowframe" > @null </item>
<item name= "Android:windownotitle" >true</item>
<item name= "Android:background" > @android:color/white</item>
<item name= "Android:windowbackground" > @android:color/white</item>
<item name= "Android:windowisfloating" >true</item>
<item name= "Android:windowcontentoverlay" > @null </item>
</style>
Android:dialog removal of the border (padding with style)