【问题标题】:Android Picture in Picture Potrait ModeAndroid 画中画肖像模式
【发布时间】:2021-02-09 03:54:07
【问题描述】:

我正在尝试实现画中画模式,但就示例而言,我看到的唯一方向是横向模式。

https://developer.android.com/guide/topics/ui/picture-in-picture

我正在尝试拥有一个功能类似于 WhatsApp 应用程序。当用户接听电话并进入画中画模式时,窗口以纵向模式显示,因此用户可以清楚地看到其他人。将不胜感激我如何实现这一点。

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.
    }
}

【问题讨论】:

    标签: android kotlin picture-in-picture android-picture-in-picture


    【解决方案1】:

    您可以使用enterPictureInPictureMode 来配置PIP 窗口。

    要使用纵向 PIP 窗口,请使用 ~2/3 的纵横比。 (纵横比必须在 0,42 和 2,39 之间。)

    override fun onUserLeaveHint() {
        enterPictureInPictureMode(PictureInPictureParams.Builder()
                .setAspectRatio(Rational(2, 3))
                .build())
    }
    

    例子:

    【讨论】:

      猜你喜欢
      • 2014-04-19
      • 1970-01-01
      • 2020-07-07
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-17
      • 2017-12-02
      相关资源
      最近更新 更多