Android custom Dialog remove black border, androiddialog

Source: Internet
Author: User

Android custom Dialog remove black border, androiddialog

There is always a black border on the Interface displayed during custom Dialog. The following describes how to remove the black border using 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: using wisfloating "> true </item> <item name =" android: windowContentOverlay "> @ null </item> <item name =" android: background "> # FFF </item> </style> <item name =" android: windowBackground "> @ drawable/actionbar_item_background </item>, the black border can be removed only after this is added.


You can also customize a transparent background image to 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: 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 = "cent Er "android: text =" TextView "android: textColor =" @ color/grey3 "android: textSize =" 18sp "/> <! -- Split line --> <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" android: gravity = "center" android: height = "50dp" android: text = "OK" android: textColor = "@ color/grey3" android: textSize = "20sp"/> </LinearLayout>





Android custom AlertDialog cannot remove the external Black edge

Yes.
It should be helpful in the future!

How can I remove the black part on the edge of my custom dialog

Is AlertDialog inherited? You can use Dialog to set your layout with setContentView.

Related Article

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.