There is always a black border in the interface that is displayed when you define dialog, and the following describes how to remove a black border using a style.
Define your own definition style first 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, just have to add this post talent to remove the black border
Or you define a transparent background image. This will also 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 "android:background=" #FFF "Android:orien tation= "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:textsize= "18sp"/> <!--cutting line--&G T <view android:id= "@+id/view_division" style= "@style/viewborder"/> <textview android:id= " @+id/login_dialog_btn "android:layout_width=" match_parent "android:layout_height=" Wrap_content "Andro id:gravity= "center" android:height= "50DP" android:text= "OK" android:textcolor= "@color/grey3" a Ndroid:textsize= "20SP"/></linearlayout>
--------------------------------------------------------------------------Gorgeous cutting line---------------------------------------- ---------------------------------
Dialog self-defined animations:
1, add in the Style.xml
<style name= "AA" parent= "@android: Style/theme.holo.light.dialog" > <item Name= "android:windowisfloating" >true</item> <item name= "Android:windowistranslucent" >false</ item> <item name= "Android:windownotitle" >true</item> <item name= "Android:windowfullscreen" >false</item> <item name= "Android:windowbackground" > @android:color/transparent</item> & Lt;item name= "Android:windowanimationstyle" > @style/dialogwindowanim</item> <item name= "Android: Backgrounddimenabled ">true</item> <item name=" Android:backgrounddimamount ">0.4</item> </ style> <style name= "Dialogwindowanim" > <item name= "android:windowenteranimation" > @anim/enter</ item> <item name= "android:windowexitanimation" > @anim/exit</item> </style>
<scale xmlns:android= "http://schemas.android.com/apk/res/android" android:duration= " android: Fromxscale= "100%" android:fromyscale= "100%" android:pivotx= "50%" android:pivoty= "50%" android: Toxscale= "50%" android:toyscale= "50%" ></scale>
2, Anim/enter.xml
<scale android:fromxscale= "50%" android:fromyscale= "50%" android:pivotx= "50%" android: Pivoty= "50%" android:toxscale= "100%" android:toyscale= "100%" > </scale>
Anim/exit.xml
3. In the Code
Used in the method Oncreatedialog of Dialogfragment
Alertdialog.builder Builder = new Alertdialog.builder (getactivity (), R.STYLE.AA);
Dialg define your own animations, OK
Android Self Definition dialog remove black border