直播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开发,系统之窗口横屏锁定以屏幕方向介绍,更多内容欢迎关注之后的文章
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球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设置背景图延伸到状态栏