Jetpack Compose 中ComposeView 绑定到Dialog中遇到的问题
文章目录
在Compose 1.2.0-alpha08 以前,可以使用以下代码
val dialog = Dialog(context)
dialog.window?.decorView?.apply {
ViewTreeLifecycleOwner.set(this, this@MainActivity)
ViewTreeViewModelStoreOwner.set(this, this@MainActivity)
ViewTreeSavedStateRegistryOwner.set(this, this@MainActivity)
}在Compose 1.2.0-alpha08以后,ViewTreeSavedStateRegistryOwner的API发生了变更
val dialog = BottomSheetDialog(this@MainActivity)
dialog.window?.decorView?.apply {
ViewTreeLifecycleOwner.set(this, this@MainActivity)
ViewTreeViewModelStoreOwner.set(this, this@MainActivity)
setViewTreeSavedStateRegistryOwner(this@MainActivity)
}参考内容
更新日志: Update ViewTreeSavedStateRegistryOwner use in Compose UI
评论
还没有留言,欢迎分享你的想法。
写下你的留言
填写即同意接收本条留言的审核通过和回复通知。邮箱仅用于通知,以加密形式保存,不会公开展示。
提交时使用 Cloudflare Turnstile 验证以减少垃圾评论。留言通过邮件送交审核,通过后随网站更新显示。支持纯文本,请勿填写隐私信息。
草稿(含昵称和邮箱)仅保存在此浏览器,提交成功后清除。