【发布时间】:2022-01-22 06:40:01
【问题描述】:
我正在制作一个应用程序并希望整合捐赠,因为它是免费的并且没有广告。我正在尝试添加一个带有 QR 码和一个肯定按钮的 AlertDialog。但是,当我使用此代码时,AlertDialog 太高(看起来很难看),您无法按下按钮。我能做些什么?谢谢。
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()
这是 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>
【问题讨论】:
-
我知道这是一个比特币地址,而代码显示的是 eth,这只是我制作的两个 AlertDialogs 之一(我复制粘贴)lol
-
可能问题出在drawable中。
-
@cmak drawable 是 1584x1584 PNG
标签: android android-studio kotlin android-alertdialog