Android Make A Dialog Appear In Fullscreen
I need the dialog to fill the screen except for some space at the top and the bottom. I've search for a solution but couldn't find one probably because I'm declaring it in an onCli
Solution 1:
here set your screen width and width to the dialog
WindowManager.LayoutParamslp=newWindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = width;
lp.height = height;
dialog.getWindow().setAttributes(lp);
or in your styles create a style like this then
<stylename="DialogTheme"parent="android:Theme.Dialog"><itemname="android:layout_width">fill_parent</item><itemname="android:layout_height">fill_parent</item><!-- No backgrounds, titles or window float --><itemname="android:windowBackground">@null</item><itemname="android:windowNoTitle">true</item><itemname="android:windowIsFloating">false</item></style>
create a dialog object like this
dialog = new Dialog(this, R.style.DialogTheme);
Edit ::
get width and height like this for any device it will fills..
WindowManagermanager= (WindowManager) getSystemService(Activity.WINDOW_SERVICE);
int width, height;
LayoutParams params;
if (Build.VERSION.SDK_INT > VERSION_CODES.FROYO) {
width = manager.getDefaultDisplay().getWidth();
height = manager.getDefaultDisplay().getHeight();
} else {
Pointpoint=newPoint();
manager.getDefaultDisplay().getSize(point);
width = point.x;
height = point.y;
}
Solution 2:
first Make custom style for dialog in style.xml file:
<stylename="full_screen_dialog"parent="@android:style/Theme.Dialog"><itemname="android:windowNoTitle">true</item><itemname="android:windowFullscreen">true</item><itemname="android:windowIsFloating">true</item><itemname="android:windowContentOverlay">@null</item><itemname="android:windowAnimationStyle">@android:style/Animation.Dialog</item><itemname="android:windowSoftInputMode">stateUnspecified|adjustPan</item><itemname="android:windowBackground">@android:color/transparent</item></style>
Then after set this theme to your Alert Dialog:
AlertDialog.Builderbuilder=newAlertDialog.Builder(newContextThemeWrapper(this, R.style.full_screen_dialog));
Or You can call new Activity and Give this Custom style to that activity as a theme in your manifest file...
Solution 3:
This may helpful for someone. I want a dialog to take full width of screen. searched a lot but nothing found useful. Finally this worked for me:
mDialog.setContentView(R.layout.my_custom_dialog);
mDialog.getWindow().setBackgroundDrawable(null);
after adding this, my dialog appears in full width of screen.
Solution 4:
try this
activity which has the Theme.Dialog style set, do this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}
Solution 5:
Make object like below theme
DialogobjD=newDialog(this, android.R.style.Theme_Translucent_NoTitleBar);
Post a Comment for "Android Make A Dialog Appear In Fullscreen"