question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Alert Dialog] Padding added on bottom when the positive button's text is a little long

See original GitHub issue

Description: When creating a MaterialAlertDialog with the positive button’s text a little long, padding gets added to the bottom of the dialog making it look out of place.

Screenshot_20200831-130148

Expected behavior: There should be no padding added.

Screenshot_20200831-133918

Source code:

MaterialAlertDialogBuilder(requireContext()).apply {
                    setTitle("Dialog title")
                    setMessage("Dialog body")
                    setPositiveButton("Agree and continue") { _, _ ->
                        
                    }
                    setNeutralButton("No") { _, _ ->
                        
                    }
                    show()                    
                }

Devices: OnePlus 6, Xiaomi Mi A2, Motorola G5 Plus Android API versions: OnePlus 6 - 29, Xiaomi Mi A2 - 28, Motorola G5 Plus - 27 Material Library version: 1.2.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
gabrielemariotticommented, Sep 1, 2020

The issue can be replicated using an emulator with these specs: https://www.gsmarena.com/oneplus_6-9109.php

Schermata 2020-09-01 alle 09 50 57 Schermata 2020-09-01 alle 09 51 49

It doesn’t happen with the appcompat AlertDialog.Builder.

Schermata 2020-09-01 alle 09 53 19
1reaction
pekingmecommented, Jun 6, 2022

Confirm this as a bug in appcompat lib. It’s been fixed in appcompat 1.4 and later. MDC 1.7.0-alpha02 has upgraded appcompat to 1.4. If you are using earlier versions, add/update appcompat to 1.4 in your build.gradle should fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dialog buttons with long text not wrapping / squeezed out
Whenever there is long text on dialog buttons, that doesn't fit the button bar width in total, the text isn't wrapped in multiple...
Read more >
[MaterialAlertDialog] Extra space below buttons if they fill the ...
Description: Whenever negative and positive buttons of a dialog are close to being stacked vertically, the MaterialAlertDialog adds some ...
Read more >
AlertDialog ignores itself's default button padding, if button ...
If I add padding to my button's text content, the AlertDialog ignores it's default button containers bottom padding of 8.dp.
Read more >
Dialogs - Material Design
Stacked buttons accommodate longer button text. Confirming actions appear above dismissive actions. Dialog with two full width text buttons, one above the other....
Read more >
Using DialogFragment | CodePath Android Cliffnotes
DialogFragment is a specialized Fragment used when you want to display an overlay modal window within an activity that floats on top of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found