1

I'm making an app and want to integrate donations since it's free and has no ads. I'm trying to add an AlertDialog with a QR code and a positive button. When I use this code, though, the AlertDialog is too tall (looks ugly), and you can't press the button. What can I do? Thanks.

enter image description here

            val inflater = this.layoutInflater
            val dialogView = inflater.inflate(R.layout.btc_layout, null)
            val builder: AlertDialog? =
                AlertDialog.Builder(this).setMessage("Click copy to copy the Bitcoin address to your clipboard")

                    .setPositiveButton("copy"){ dialog, which ->
                        val clipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
                        val address = ClipData.newPlainText("text", "3KekRCkMo7pC9Rd1u5JtQQPdxnXD1cUfnM")
                        clipboardManager.setPrimaryClip(address)

                        Toast.makeText(
                            this@donations,
                            "copied!",
                            Toast.LENGTH_SHORT
                        ).show()

                    }.setView(dialogView).show()

this is btc_layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/btc">
    </ImageView>

</androidx.constraintlayout.widget.ConstraintLayout>
Tenfour04
  • 83,111
  • 11
  • 94
  • 154
Marvil
  • 83
  • 1
  • 6

1 Answers1

0

I figured it out. I just set the layout_gravity in the XML file to center, and changed the width and height to match the AlertDialog.

Marvil
  • 83
  • 1
  • 6