Alert Dialog Box or Custom Alert Dialog Box

I create my application for all tablets 10.1 and now I try this on the galaxy galaxy tab. I have done all parts of this, but the warning dialog is too small relative to tablet size. I also created a custom alert dialog, but it doesnโ€™t look very good. So tell me if I can resize the default warning dialog, if so, how.

OR

how to create a custom alert dialog that looks like the default alert dialog.

Thank.

+6
android
Jan 12 2018-12-12T00:
source share
1 answer

Refer to this

According to Android platform developer Dianne Hackborn in this group discussion column, Dialogs set the width and height of the top-level layout of the WRAP_CONTENT window. To make the Dialog bigger, you can set these parameters to FILL_PARENT.

Demo code:

AlertDialog.Builder adb = new AlertDialog.Builder(this); Dialog d = adb.setView(new View(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.LayoutParams lp = new WindowManager.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 box is displayed. The system is very complex when they are installed. (I assume that the layout engine should install them the first time the dialog is displayed, or something like that.)

It would be better to do this by expanding the .Dialog theme, then you would not have to play a fortunetelling game about when to call setAttributes. (Although itโ€™s a bit more work to make the dialog automatically accept the corresponding light or dark theme or Honeycomb Holo theme. This can be done according to http://developer.android.com/guide/topics/ui/themes.html#SelectATheme )

+12
Jan 12 2018-12-12T00:
source share



All Articles