【html5】腊鸭Layaair2.0用LayaNative打包apk强制竖屏的设置要点

版权声明:本文为博主原创文章,如需转载请注明出处,谢谢。喜欢请关注哟~ https://blog.csdn.net/sjt223857130/article/details/83090203

屏幕适配设置的地方挺多,官方文档比较分散。

在这里收集一下需要设置的几个地方。Android项目生成安卓apk运行后适配强制竖屏为例。

【安卓项目】AndroidManifest.xml

android:screenOrientation="portrait"

【Laya项目】\bin\index.js

/**
 * 设置LayaNative屏幕方向,可设置以下值
 * landscape           横屏
 * portrait            竖屏
 * sensor_landscape    横屏(双方向)
 * sensor_portrait     竖屏(双方向)
 */
window.screenOrientation = "portrait";

【Laya项目】\bin\index.html

<meta name='laya' screenorientation='portrait' />

【Laya项目】配置文件在设计视图按F9

  static scaleMode:string="exactfit";
    static screenMode:string="vertical";
    static alignV:string="middle";
    static alignH:string="center";

以上缺一不可。不得不说,Layaair的配置设计,弱爆了,这么多地方。。。

需要其它模式,可以参考的值如下:

unspecified,默认值,由系统决定,不同手机可能不一致
landscape,强制横屏显示
portrait,强制竖屏显
behind,与前一个activity方向相同
sensor,根据物理传感器方向转动,用户90度、180度、270度旋转手机方向,activity都更着变化
sensorLandscape,横屏旋转,一般横屏游戏会这样设置
sensorPortrait,竖屏旋转
nosensor,旋转设备时候,界面不会跟着旋转。初始化界面方向由系统控制
user,用户当前设置的方向

LAYA官方文档都是一盘散沙 ~ 

猜你喜欢

转载自blog.csdn.net/sjt223857130/article/details/83090203