Search code examples
androidkotlinanko

Anko - Custom Alert not showing


I made this alert using Anko DSL and is not showing in devices with small resolution.

   dialog = alert {
                customView {
                    verticalLayout {
                        backgroundColor = Color.WHITE
                        textView {
                            text = context.getString(R.string.delete_sessions)
                            padding = 8
                            textSize = 16f
                            textAlignment = View.TEXT_ALIGNMENT_CENTER
                            textColor = Color.BLACK
                            typeface = ResourcesCompat.getFont(context, R.font.rubik)
                        }
                        linearLayout {
                            gravity = Gravity.END
                            padding = 16
                            button {
                                text = context.getString(R.string.no)
                                textColor = Color.parseColor("#FF1A40")
                                backgroundColor = Color.WHITE
                                onClick {
                                    dialog.dismiss()
                                }
                            }
                            button {
                                text = context.getString(R.string.yes)
                                textColor = Color.parseColor("#3A92CC")
                                backgroundColor = Color.WHITE
                                onClick {
                                    dialog.dismiss()
                                    val list = [email protected]()
                                    if (list != null)
                                        vm.deleteList(list)

                                }
                            }
                        }
                    }
                }
            }.show()

If I don't use all content inside customview{ } it works. For example:

alert{
  message = "something"
   customView{}
}.show()

In high resolution devices, the alert shows fine. I'm testing in a 5' with 1080x1920 with density 480 (Genymotion)


Solution

  • I removed the typeface and it worked.

    typeface = ResourcesCompat.getFont(context, R.font.rubik)