AlertDialog AppCompat width and height

android, android-alertdialog

Solution

If it is a customizes dialog box then you can set the height and width in new created XML file only. but if you are using AlertDialog.builder then use this.

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
builder.setTitle("Title");
alertDialog = builder.create();
alertDialog.show();
alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.

And follow this Hope it may help you out.

Problem

My custome style for AlertDialog look like: ``` <style name="Testing.Dialog" parent="Theme.AppCompat.Light.Dialog.Alert"> <item name="colorAccent">@color/color_accent</item> <item name="android:textColorPrimary">@color/text_color_primary</item> <item name="android:background">@color/color_primary</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> </style> ``` I need change width and height, because it is too large on my tablet. Any ideas? Below code not working properly: ``` <item name="windowMinWidthMajor">@dimen/abc_dialog_min_width_major</item> <item name="windowMinWidthMinor">@dimen/abc_dialog_min_width_minor</item> ```

Original source

Related problems