直播app开发,系统之窗口横屏锁定以屏幕方向介绍

直播app开发,系统之窗口横屏锁定以屏幕方向介绍

android源码中通过PhoneWindowManager.java来管理窗口的显示,为WMS的一个主要部分。其源码地址如下:

 

1
<br>frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java

PhoneWindowManager关于屏幕方向控制的主要代码如下:

 

1
<br>    int mLandscapeRotation = 0;  // default landscape rotation<br>    int mSeascapeRotation = 0;   // "other" landscape rotation, 180 degrees from mLandscapeRotation<br>    int mPortraitRotation = 0;   // default portrait rotation<br>    int mUpsideDownRotation = 0; // "other" portrait rotation<br>@Override<br>    public void setInitialDisplaySize(Display display, int width, int height, int density) {<br>        ...代码省略<br>        final Resources res = mContext.getResources();<br>        int shortSize, longSize;<br>        if (width > height) {<br>            shortSize = height;<br>            longSize = width;<br>            mLandscapeRotation = Surface.ROTATION_0;<br>            mSeascapeRotation = Surface.ROTATION_180;<br>            if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) {<br>                mPortraitRotation = Surface.ROTATION_90;<br>                mUpsideDownRotation = Surface.ROTATION_270;<br>            } else {<br>                mPortraitRotation = Surface.ROTATION_270;<br>                mUpsideDownRotation = Surface.ROTATION_90;<br>            }<br>        } else {<br>            shortSize = width;<br>            longSize = height;<br>            mPortraitRotation = Surface.ROTATION_0;<br>            mUpsideDownRotation = Surface.ROTATION_180;<br>            if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) {<br>                mLandscapeRotation = Surface.ROTATION_270;<br>                mSeascapeRotation = Surface.ROTATION_90;<br>            } else {<br>                mLandscapeRotation = Surface.ROTATION_90;<br>                mSeascapeRotation = Surface.ROTATION_270;<br>            }<br>        }

 

 以上就是 直播app开发,系统之窗口横屏锁定以屏幕方向介绍,更多内容欢迎关注之后的文章

 

posted @   云豹科技-苏凌霄  阅读(16)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
历史上的今天:
2022-05-30 直播app开发,Android ListView好友列表展示
2022-05-30 直播平台开发,防止直播过程中被截屏或录屏
2022-05-30 短视频开发app,Android设置背景图延伸到状态栏
点击右上角即可分享
微信分享提示