problem: Custom Alertdialog appear black Edge
To
run a code snippet:
View view = View.inflate(context, R.layout.dialog_common, null);mDialog = new AlertDialog.Builder(context).create();mDialog.setView(view);mDialog.show();
Dialog_common.xml
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" match_parent " android:layout_height=" Wrap_ Content " android:background=" @drawable/shape_dialog_white " android:o rientation= "Vertical" > <LinearLayout android: Layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_marginbottom= "35DP" android:layout_margintop= "35DP" android:gravity= "center" > <TextView android:id= "@+id/dialog_tv_content" Android:layOut_width= "Wrap_content" android:layout_ height= "Wrap_content" android:text= "@string/ Dialog_edit_wall_title " android:textcolor=" @ Android:color/black " android:textsize=" 19SP "/ > </LinearLayout> <View android:layout_width= "match_parent" android:layout_height= "1DP" android:background= "@color/app_color"/> < linearlayout android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android: Gravity= "CenteR "> <TextView android:id= "@+id/dialog_tv_left" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android: Layout_marginbottom= "12DP" android:layout_ margintop= "12DP" android:layout_weight= "1" android:gravity= "center" android:text= "@string/dialog_edit_wall_secede" android:textcolor= "@android: Color/black"/> <TextView android:id= "@+id /dialog_tv_right " android:layout_width=" Wrap_ Content " android:layout_height=" Wrap_content " android:layout_marginbottom= "12DP" android:layout_margintop= "12DP" android:layout_weight= "1" android:gravity= "center" android:text= "@string/dialog_new_reply_cancel" android:textcolor= "@color/app_color"/> </linearlayout></ Linearlayout>
Run-time (there is a circle of black edges!) ):
solve the problem:
1. Baidu Search "Android custom Alertdialog Remove Black edge", to conclude 3 words: "Then egg"! Most of them do this:
Modify
code:
mDialog.setView(view);
is:
mDialog.setView(view,0,0,0,0);
run time (what is called "but the egg", the thick black edge becomes the thin black edge, the result black edge is still in):
2. Analysis: The layout of your own writing is not a problem, obviously alertdialog style or theme problem.
3. Ultimate Solution:
Add a style
<!--styles.xml on API 14+ devices--> <style name= "Sampletheme.light" parent= " Android:Theme.Holo.Light.DarkActionBar "> <item name=" Android: Windownotitle ">true</item> </style>
add to Layout or androidmanifest.xml (I was added to Androidmanifest.xml, layout can be added to see for yourself )
)
<activity android:name="com.kesar.ui.MainActivity" android:theme="@style/SampleTheme.Light"/>
runtime (Next is the time to witness miracles!) ):
From for notes (Wiz)
List of attachments
Android Custom Alertdialog Ultimate Solution (pro-Test effective!) )