Based on the code here, http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog . I am successfully able to create a custom dialog with background and buttons ins
Make a class like this:
public class CustomDialog extends Dialog {
public AlertFinishiView(Context context) {
super(context);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dialog);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
}
make a xml in layut folder with this name dialog
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="220dp"
android:layout_height="140dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/bg_custom_dialog" >
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Button" />
</RelativeLayout>
</RelativeLayout>
add the image above in your drawable folder with name bg_custom_dialog.9.png
call in your activity:
CustomDialog customDialog = new CustomDialog(this);
customDialog.show();
Use this, It works perfectly;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before
dialog.setContentView(R.layout.your_dialog_layout);