Android custom dialog Remove black border

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.