Skip to content Skip to sidebar Skip to footer

Size Of Alert Dialog Or Custom Alert Dialog

I am creating my application for all tablets of 10.1 and now i am trying this on samsung galaxy tab. I have done all the parts of that but alert dialog is too small regarding table

Solution 1:

Please Refer this one

According to Android platform developer Dianne Hackborn in this discussion group post, Dialogs set their Window's top level layout width and height to WRAP_CONTENT. To make the Dialog bigger, you can set those parameters to FILL_PARENT.

Demo code:

AlertDialog.Builderadb=newAlertDialog.Builder(this);
Dialogd= adb.setView(newView(this)).create();
// (That new View is just there to have something inside the dialog that can grow big enough to cover the whole screen.)

WindowManager.LayoutParamslp=newWindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
d.show();
d.getWindow().setAttributes(lp);

Note that the attributes are set after the Dialog is shown. The system is finicky about when they are set. (I guess that the layout engine must set them the first time the dialog is shown, or something.)

It would be better to do this by extending Theme.Dialog, then you wouldn't have to play a guessing game about when to call setAttributes. (Although it's a bit more work to have the dialog automatically adopt an appropriate light or dark theme, or the Honeycomb Holo theme. That can be done according to http://developer.android.com/guide/topics/ui/themes.html#SelectATheme )

Post a Comment for "Size Of Alert Dialog Or Custom Alert Dialog"