You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中使用PlatformView展示Android Native视图对齐异常求助

问题:Flutter封装Android原生插件时KLivenessView对齐异常

我正在为Flutter封装一款Android原生插件,严格遵循Flutter官方文档完成实现:通过原生端的PlatformView和Flutter端的AndroidView组件展示Android原生UI。TextView、WebView等常规原生视图显示正常,但插件提供的KLivenessView(需在黄色圆圈内展示相机流)出现对齐异常,该插件在其他Android原生项目中运行正常。

原生端代码片段

class FlutterWebView internal constructor(
    context: Context,
    messenger: BinaryMessenger,
    id: Int,
    activity: Activity
) :
    PlatformView,KLivenessCallbacks, MethodCallHandler, AppCompatActivity() {
    val activity=activity
    val context=context
    private val kLivenessView: KLivenessView
    private  var methodChannel: MethodChannel
    override fun getView(): View {
        return kLivenessView//this is the object of UI class provided by plugin
    }

    init {
        
        kLivenessView = KLivenessView(context)
    }
}

异常显示截图

相机流对齐异常截图

内容的提问来源于stack exchange,提问作者shivani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 22:20:27