There is always a black border in the interface that is displayed when customizing dialog, and the following describes how to remove a black border using a style.
First define the custom style in Values/styles:
<style name= "Mydialog" parent= "@android: Theme.dialog" > <item name= "Android:windowframe" > @null < /item> <item name= "Android:windowbackground" > @drawable/actionbar_item_background</item> <item name= "Android:windownotitle" >true</item> <item name= "android:windowisfloating" >true </item> <item name= "Android:windowcontentoverlay" > @null </item> <item name= "Android: Background "> #FFF </item> </style><item name=" Android:windowbackground "> @drawable/ Actionbar_item_background</item> This is the point, only add this after you can remove the black border
Or customize a transparent background image so you can remove the black border!
Code:
Static class Msgdialog extends Dialog implementsandroid.view.View.OnClickListener {private String text;public Msgdialog (Context context, String text) {Super (context, r.style.mydialog); this.text = text;} @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.login_dialog); TextView txt = (TextView) Findviewbyid (r.id.login_dialog_txt); Txt.settext (text); TextView confirm = (TextView) Findviewbyid (R.ID.LOGIN_DIALOG_BTN); Confirm.setonclicklistener (this);} @Overridepublic void OnClick (View v) {MsgDialog.this.dismiss ();}}
Xml:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Wrap_content "android:layout_height=" wrap_content "android:paddingtop=" 5DP "and Roid:background= "#FFF" android:orientation= "vertical" > <textview android:id= "@+id/login_dialog_txt" Android:layout_width= "Match_parent" android:layout_height= "wrap_content" android:layout_gravity= "center "android:gravity=" center "android:text=" TextView "android:textcolor=" @color/grey3 "Android:te Xtsize= "18sp"/> <!--split Line--<view android:id= "@+id/view_division" style= "@style/viewbord Er "/> <textview android:id=" @+id/login_dialog_btn "android:layout_width=" Match_parent "Android oid:layout_height= "wrap_content" android:gravity= "center" android:height= "50DP" android:text= "OK" Android:textcolor= "@color/grey3"Android:textsize=" 20SP "/></linearlayout>
Android custom dialog Remove black border