Jetpack Compose AbstractComposeView弹出窗口显示为黑色的问题求助
Jetpack Compose AbstractComposeView弹出窗口显示为黑色的问题求助
大家好,我遇到了一个头疼的问题:我用AbstractComposeView创建了一个弹出视图,在Android Studio模拟器上打开时,这个弹出窗口的大部分区域都是黑色的。目前只有两个按钮是可见的,文本框虽然能选中,但窗口其余部分全黑,完全看不到正常的内容。
(原本配有两张场景截图,展示黑色的弹出窗口状态)
下面是我用来创建这个视图的代码:
class Swim_Set_Adder( composeView: View, private val Workout_Point: Workout ) : AbstractComposeView(composeView.context) { private val windowManager = composeView.context.getSystemService(Context.WINDOW_SERVICE) as WindowManager private var params: WindowManager.LayoutParams = WindowManager.LayoutParams().apply { type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL token = composeView.applicationWindowToken width = WindowManager.LayoutParams.WRAP_CONTENT height = WindowManager.LayoutParams.WRAP_CONTENT format = PixelFormat.OPAQUE } private var viewShowing = false init { ViewTreeLifecycleOwner.set(this, ViewTreeLifecycleOwner.get(composeView)) ViewTreeViewModelStoreOwner.set(this, ViewTreeViewModelStoreOwner.get(composeView)) setViewTreeSavedStateRegistryOwner(composeView.findViewTreeSavedStateRegistryOwner()) } @ExperimentalComposeUiApi @Composable override fun Content() { Show() } fun show() { if (viewShowing) dismiss() windowManager.addView(this, params) viewShowing = true } fun dismiss() { if (!viewShowing) return disposeComposition() windowManager.removeViewImmediate(this) viewShowing = false } fun dispose() { dismiss() setViewTreeSavedStateRegistryOwner(null) ViewTreeLifecycleOwner.set(this, null) ViewTreeViewModelStoreOwner.set(this, null) } }
我现在的目标是让这个弹出窗口能正常显示,让所有文本框都能被看到,有没有大佬能帮我分析下问题出在哪?
备注:内容来源于stack exchange,提问作者user21779968
相关产品推荐
相关产品推荐

