Android – width and height of alertdialog appcompat

My customer style for alertdialog is as follows:

<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 to change the width and height because it's too big on my tablet. Any ideas?

The following code does not work properly:

   <item name="windowMinWidthMajor">@dimen/abc_dialog_min_width_major</item>
   <item name="windowMinWidthMinor">@dimen/abc_dialog_min_width_minor</item>

resolvent:

If it is a custom dialog box, you can only set the height and width in the newly created XML file. However, if you use alertdialog.builder, you can use it

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 can help you

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>