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>
I was able to adjust the width like so:
<style name="NarrowDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="windowFixedWidthMajor">70%</item>
<item name="windowFixedWidthMinor">70%</item>
</style>
Dialog dialog = new AlertDialog.Builder(this, R.style.NarrowDialog)...
There is also a minimum width you might wish to adjust:
<item name="windowMinWidthMajor">65%</item>
<item name="windowMinWidthMinor">65%</item>
Attribute details:
windowFixedHeightMajor
: A fixed height for the window along the major axis of the screen, that is, when in portrait.
windowFixedHeightMinor
: A fixed height for the window along the minor axis of the screen, that is, when in landscape.
windowFixedWidthMajor
: A fixed width for the window along the major axis of the screen, that is, when in landscape.
windowFixedWidthMinor
:A fixed width for the window along the minor axis of the screen, that is, when in portrait.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With