Evgeni Roitburg
Evgeni Roitburg

Reputation: 2097

Android material dialog actions panel height

Here is the official material dialog spec:

enter image description here

I would like to increase the action panel height(52dp)/paddings(8dp) to get more space around the buttons. Is there a proper way to do so via styles?

Upvotes: 1

Views: 211

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364451

You can do it using:

<style name="AlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
    <item name="buttonBarStyle">@style/myButtonBar</item>
</style>

<style name="myButtonBar" parent="Widget.AppCompat.ButtonBar">
    <item name="android:paddingTop">32dp</item>
    <item name="android:paddingBottom">32dp</item>
</style>

and then just use:

new MaterialAlertDialogBuilder(context,R.style.AlertDialog)
        .setTitle("...")
        .setMessage(".....")
        ...
        .show();

enter image description here

Upvotes: 2

Corentin Houdayer
Corentin Houdayer

Reputation: 988

You have multiple options such as:

  • Overriding default material dimensions in your own dimens.xml (not recommended)
  • Creating your own style by inheriting your theme from component's Material theme

Please take a look at this example, you should find what you need:

https://medium.com/over-engineering/setting-up-a-material-components-theme-for-android-fbf7774da739

Upvotes: 0

Related Questions