0

How do I achieve Alert Dialog Button style like this :

Google Photos App

Do I have to create a custom "Dialog" or this can be achieved via AlertDialog theming?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841

3 Answers3

0

You customize your dialog screen like create normal activity screen but you search different dialog screen try this library.

Dynasty
  • 29
  • 4
0

You should use this library for beatiful dialog

https://github.com/pedant/sweet-alert-dialog

0

Just use the MaterialAlertDialogBuilder using a custom style:

  new MaterialAlertDialogBuilder(MainActivity.this, 
            R.style.MyThemeOverlay_MaterialComponents_MaterialAlertDialog)
              .setTitle("Keep backup off?")
              .setMessage("Backup is free and unlimited at high quality")
              .setPositiveButton("Turn on", null)
              .setNegativeButton("Keep off", /* listener = */ null)
              .show();

Use the buttonBarPositiveButtonStyle and buttonBarNegativeButtonStyle attributes to change the default color.
In this case you can use a filled button (Widget.MaterialComponents.Button) for the positive button and a Text Button (Widget.MaterialComponents.Button.TextButton.Dialog) for the negative button.

  <style name="MyThemeOverlay.MaterialComponents.MaterialAlertDialog" parent="@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog">

    <item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
    <item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
  </style>

  <style name="PositiveButtonStyle" parent="@style/Widget.MaterialComponents.Button">
    <item name="android:textColor">#FFFFFF</item>
    <item name="backgroundTint">@color/primaryDarkColor</item>
  </style>

  <style name="NegativeButtonStyle" parent="@style/Widget.MaterialComponents.Button.TextButton.Dialog">
    <item name="android:textColor">@color/primaryDarkColor</item>
  </style>

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841