0

I attached an image of what the title is about, the title of dialog gets cut off and I dont understand why, I saw some alert dialog only works for 2 lines is this the issue?

Error

    private fun remindAcceptOrders(newStatus: OrderStatus, orderDetails: OrderDetails) {
            val dialog = AlertDialog.Builder(requireContext(), R.style.AlertDialogTheme)

                .setTitle(
                    getString(R.string.acceptMessage2)
                )

                .setPositiveButton(R.string.acceptorder) { dialog, _ ->

                    newStatus == ACCEPTED
                    showNewStatusConfirmationPopup(ACCEPTED, orderDetails)
                    dialog.dismiss()
                }

                    .setNegativeButton(R.string.exit) {
                        dialog, _ -> dialog.dismiss()
                        navc!!.navigate(R.id.action_orderDetailsFragment_to_orderListFragment)
                    }
                .setMessage(
                    getString(R.string.acceptMessage1)
                )
                .create()
            dialog.show()


            val textView = dialog.findViewById<View>(android.R.id.message) as TextView?
            textView!!.textSize = 15f
            textView!!.maxLines = 3[enter image description here][1]
        }
Ugur d
  • 1
  • 3
  • The reason the behavior is like this is because general UI convention is for a dialog title not to have more than 2-3 words. If it does, and if you want to fit in with what users are used to, you should modify the title to be very short and put more of the content in the message. – Tenfour04 Aug 09 '21 at 13:24

2 Answers2

0

This can be solved using a custom title TextView

val customeTv = TextView(context);
textView.setText(getString(R.string.acceptMessage2));

val dialog = AlertDialog.Builder(requireContext(), R.style.AlertDialogTheme)
                .setCustomTitle(textView)
...

as stated in documentation, custom Title allows you to make any required modifications

The methods setTitle(int) and setIcon(int) should be sufficient for most titles, but this is provided if the title needs more customization. Using this will replace the title and icon set via the other methods.

mightyWOZ
  • 7,946
  • 3
  • 29
  • 46
0

You can create Custom alert so your text fully show as you want, for that follow below link: How to create a Custom Dialog box in android?

Vijay Chaudhary
  • 228
  • 2
  • 12