well, you can create an AlertDialog in a user view, in that user view only assign the desired background. Later set this view as a custom view of AlertDialog. example: - RelativeCustomLayout:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@drawable/shape_1" android:padding="10dip"> ............ </RelativeLayout>
now inflate this view and configure it as a custom dialog view
protected void createCustomDialog(int drawable, String title, String message){ LayoutInflater inflater = LayoutInflater.from(WkActivity.this); View customDialog = inflater.inflate(R.layout.generic_error_dialog, null); ((TextView)customDialog.findViewById(R.id.genericErrorDialogTitle)).setText(title); ((TextView)customDialog.findViewById(R.id.genericErrorDialogMessage)).setText(message); ((ImageView)customDialog.findViewById(R.id.genericErrorDialogIcon)).setImageResource(drawable); dialog = new AlertDialog.Builder(WkActivity.this).create(); dialog.setView(customDialog); dialog.setButton(getText(R.string.listaBusquedasGuardadasNoResultDialogButton), onClickListener); dialog.show(); }
hope this helps
source share