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.