Reputation: 133
I would like to have the dialog to be full screen of the phone. I've tried several method found various places. Coding is :
@Override
public void onCreate(Bundle saveBundle) {
super.onCreate(saveBundle);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams params = getWindow().getAttributes();
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
params.x = 0;
params.y = 0;
params.height = size.y;
params.width = size.x;
getWindow().setAttributes(params);
}
Both setting flag to FLAG_FULLSCREEN and setting the dialog size are not working. There are spacing on two sides and at the top.
I am able to reduce the spaces by setting the position and size with hard code numbers like:
params.x = -30;
params.y = -40;
params.height = size.y + 30;
params.width = size.x + 60;
Any suggestion to fix this properly ?
Upvotes: 0
Views: 544
Reputation: 1277
I am Also suffering this problem and I am doing lot's of R&d to set Dialog in full screen but I get Same Result.Lot's of Code working fine but in some device Dialog is not Display Proper.So At the end finally I Decide to Set minHeight and minWidth of Dialog Layout.Following Code is Working fine in My Case.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="@dimen/dp_900"
android:minHeight="@dimen/dp_900"
>
<!--MY LAYOUT DESIGN-->
I hope you are clear with my Idea.
Best of Luck
Upvotes: 0
Reputation: 338
Try to modify dialogs layout parameters.....
localDialog = new Dialog(context);
localDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = localDialog.getWindow().getAttributes();
wmlp.width=LayoutParams.FILL_PARENT;
wmlp.height=LayoutParams.FILL_PARENT;
Upvotes: 0
Reputation: 2017
Try this code to create your dialog:
dialog = new Dialog(getActivity(),android.R.style.Theme_Translucent_NoTitleBar);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.loading_screen);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.CENTER;
wlp.flags &= ~WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
window.setAttributes(wlp);
dialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.MATCH_PARENT);
dialog.show()
Upvotes: 0
Reputation: 1077
Try this,
dialog = new Dialog(context,android.R.style.Theme_Transculent_NoTitleBar_FullScreen);
Upvotes: 1