I want to dialog appears in center I use this code .
public void dialog(View v){
Dialog d=new Dialog(this);
d.setContentView(R.layout.dl_search);
d.setCancelable(true);
d.show();
}
Appear the dialog in center .
But when I add this code .
d.getWindow().setBackgroundDrawable(new BitmapDrawable(getResources(),blurbitmap));
The dialog appear in top & left .
....
**I want to be dialog in center ** Thanks for help
Use this:
Window window = customdialog.getWindow();
window.setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.CENTER);
or Try:
android:gravity="center_vertical|center_horizontal"