【问题标题】:How to detect picture in popup dismissed (drag down to dismiss)?如何检测弹出窗口中的图片已关闭(向下拖动以关闭)?
【发布时间】:2020-06-11 05:40:16
【问题描述】:

我们正在使用带有画中画(pip)功能的通话页面。

问题:
如果用户关闭 pip 弹出窗口(通过向下拖动关闭)我们无法检测到。

如何检测图片窗口中的图片下拉关闭?

更新:
设置画中画

// RemoteRenderLayout -> call preview layout. You can set anyone view
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

    Rational aspectRatio = new Rational(
        remoteRenderLayout.getWidth(), remoteRenderLayout.getHeight());
    PictureInPictureParams params = new PictureInPictureParams.Builder()
        .setAspectRatio(aspectRatio)
        .build();
    enterPictureInPictureMode(params);
}
else{

    enterPictureInPictureMode();
}

【问题讨论】:

  • "pip 弹出窗口" 你是什么意思?您用于创建它的 Android api 的具体部分。提供您必须创建的代码,然后我们可能会提供帮助。
  • "pip popup window" -> 画中画窗口(小方块)官方文档 - developer.android.com/guide/topics/ui/picture-in-picture@MarianPaździoch
  • @Ranjith - 你能提供一些代码来审查一些经过尝试的方法来实现期望的结果..?
  • @MarioBoss 问题已更新为示例代码

标签: android android-picture-in-picture


【解决方案1】:

当activity进入或退出画中画模式时,系统调用Activity.onPictureInPictureModeChanged()或Fragment.onPictureInPictureModeChanged().

您可以在其中实现您的代码:

 override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean,
                                           newConfig: Configuration) {
    if (isInPictureInPictureMode) {
        // Hide the full-screen UI (controls, etc.) while in picture-in-picture mode.
    } else {
        // Restore the full-screen UI.
    }
}

【讨论】:

    猜你喜欢
    • 2019-11-12
    • 1970-01-01
    • 1970-01-01
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多