HarmonyOS 视频切换至横屏后,视频没有占满全屏?

使用如下代码切换横竖屏,横屏状态下视频没有占满。

private screenOrientationChange(isLandscape: boolean) {
  this.isLandscape = isLandscape
  // 获取UIAbility实例的上下文信息
  let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
  // 调用该接口手动改变设备横竖屏状态
  window.getLastWindow(context).then((lastWindow) => {
    lastWindow.setPreferredOrientation(this.isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT)
  });
}
阅读 502
1 个回答

可以在父组件中使用onBackPress,onBackPress当用户点击返回按钮时触发,仅@Entry装饰的自定义组件生效。返回true表示页面自己处理返回逻辑,不进行页面路由;返回false表示使用默认的路由返回逻辑,不设置返回值按照false处理。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进