I am trying to add a border for a dialog window in Android. Have added rounded corners to the dialog window using a drawable with the following lines
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="5dp"
android:right="5dp"
android:bottom="5dp"
android:top="5dp">
<shape android:shape="rectangle">
<solid android:color="#ffbf80" />
<corners android:radius="30dp" />
<padding
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
</shape>
</item>
</layer-list>
To add border to the dialog box, I tried by adding the stroke element as below
<shape android:shape="rectangle">
<solid
android:color="#ffbf80" />
<stroke android:color="#ff3300" android:width="2dp"/>
<corners
android:radius="30dp" />
<padding
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
</shape>
But this is creating a border around every element in the dialog like textview, icon, button also. I just want an outline border for the window.
I have created the alert dialog in the java code using AlertDialog.Builder,
myDialogBuilder=new AlertDialog.Builder(new
ContextThemeWrapper(getActivity(),
R.style.CustomDialog))
.setTitle(title.getText().toString())
.setMessage(myText)
.setPositiveButton("Done", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
getDialog().dismiss();
}
});
myDialog=myDialogBuilder.create();
myDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Window view=((AlertDialog)dialog).getWindow();
view.setBackgroundDrawable(new
ColorDrawable(Color.TRANSPARENT));
...
}
});
I have the following in my styles.xml for the dialog box
<style name="CustomDialog" parent="@style/ThemeOverlay.AppCompat.Dialog">
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">@drawable/dialog_bg</item>
<item name="android:textColorPrimary">@color/my_textcolor</item>
</style>
Please help me understand what changes should I make so that the alert dialog border gets displayed.
Thanks