1

Currently, I am trying to create a materialalertdialog that should scale with the screen size. For example, the text size and the buttons should get bigger on tablets than they are on normal phone screens. But whatever I do, I don't seem to achieve this behavior.

Screen Default Phone

enter image description here

Screen Tablet (too small text, buttons etc)

enter image description here

Code

MaterialAlertDialogBuilder(requireContext())
     .setTitle("TITLE)
     .setMessage("MESSAGE)
     .setPositiveButton("POSITIVEBUTTONTEXT) { dialog, _ -> doStuff() }
     .setNegativeButton("NEGATIVBUTTON) { dialog, _ -> doOtherStuff() }
     .show()

My Question is: How can I change the size of the buttons text, the title and message size etc. when a tablet / bigger screen is used?

NearHuscarl
  • 66,950
  • 18
  • 261
  • 230
Andrew
  • 4,264
  • 1
  • 21
  • 65
  • I'm on mobile so i can't post the code, but the idea is to create a custom style, there you can set the text size which also references to dimmens.xml, and those dimensions change depending of screen size – javdromero Mar 20 '21 at 19:51
  • Well the problem is you can only set a custom style for what is within the dialog and not outside it. For example, the custom style does not change the size of the text buttons. – Andrew Mar 20 '21 at 19:58
  • What about [this](https://stackoverflow.com/questions/6562924/changing-font-size-into-an-alertdialog) ? Have you tried with MaterialAlertDialogBuilder ? – javdromero Mar 20 '21 at 20:00
  • Nah all the solutions are absolute crap and do not answer my question as I have to change the font size when a given Screen Width is met. – Andrew Mar 20 '21 at 20:07
  • Yeah, they are not working right now, an alternative would be to use .setView(myDialog) then you draw your buttons and everything else on the xml – javdromero Mar 20 '21 at 20:17

0 Answers0