在 TWA 中锁定方向 [英] Lock orientation in TWA

查看:72
本文介绍了在 TWA 中锁定方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这篇文章从一个 PWA.一切都很好,应用感觉像 PWA,但我无法实现的是将方向锁定为横向.

I followed this article to make a TWA from a PWA. Everything is fine and the app feels like the PWA, but what I can't achieve is to lock the orientation to landscape.

PWA 的清单是这样的:

The manifest of the PWA has this:

"orientation": "风景",显示":独立"

因此,如果您将其从 Google chorme 添加到主屏幕,它会按预期工作.

So if you add it to the homescreen from Google chorme it works as intended.

我尝试在清单文件中设置 android:screenOrientation="landscape" 并像这样在横向上启动应用程序但它没有锁定它.

I tried setting the android:screenOrientation="landscape" in the manifest file and like this starts the app on landscape but it doesn't lock it.

有人试过锁定它吗?

推荐答案

自定义选项卡目前不提供允许开发人员锁定方向的 API.":

"Custom Tabs does not currently provide an API that allows the developer to lock the orientation.":

https://stackoverflow.com/a/38700267/887595

您可以尝试使用媒体查询的方向锁定"方法:

You could try the "Orientation Lock" method using media queries:

https://css-tricks.com/snippets/css/orientation-锁/

这篇关于在 TWA 中锁定方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆