Android P 横屏 部分应用宽度未占满屏幕
Posted dudu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android P 横屏 部分应用宽度未占满屏幕相关的知识,希望对你有一定的参考价值。
frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
/**
* Computes the bounds to fit the Activity within the bounds of the {@link Configuration}.
*/
// TODO(b/36505427): Consider moving this method and similar ones to ConfigurationContainer.
private void computeBounds(Rect outBounds)
能正常显示的activity信息:
0417 01-01 17:27:31.716: I/ActivityManager(10568): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000100 cmp=com.android.launcher3/.Launcher} from pid 0 uid 0
0437 01-01 17:27:31.786: D/ActivityManager(10568): [computeBounds] info = ActivityInfo{bd4978b com.android.launcher3.Launcher}
0438 01-01 17:27:31.786: D/ActivityManager(10568): [computeBounds] task inMultiWindowMode ? false
0439 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] maxAspectRatio === 0.0
0440 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] getConfiguration() == {1.0 ?mcc?mnc [zh_CN] ldltr sw426dp w1925dp h402dp 120dpi nrml long hdr land finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1444, 320) mAppBounds=Rect(0, 0 - 1444, 320) mWindowingMode=fullscreen mActivityType=home} s.4}
0441 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] isInVrUiMode(getConfiguration()) == false
0442 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] maxAspectRatio = 0.0
0443 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] task.inMultiWindowMode() = false
0444 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] getConfiguration() = {1.0 ?mcc?mnc [zh_CN] ldltr sw426dp w1925dp h402dp 120dpi nrml long hdr land finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1444, 320) mAppBounds=Rect(0, 0 - 1444, 320) mWindowingMode=fullscreen mActivityType=home} s.4}
0445 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] isInVrUiMode(getConfiguration()) = false
0446 01-01 17:27:31.787: D/ActivityManager(10568): [computeBounds] return
只能显示半屏的应用:
1186 01-01 17:27:44.124: I/ActivityManager(10568): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.calendar/.AllInOneActivity bnds=1153,65} from pid 11071 uid 10018
1205 01-01 17:27:44.148: D/ActivityManager(10568): [computeBounds] info = ActivityInfo{6033324 com.android.calendar.AllInOneActivity}
1206 01-01 17:27:44.148: D/ActivityManager(10568): [computeBounds] task inMultiWindowMode ? false
1207 01-01 17:27:44.148: D/ActivityManager(10568): [computeBounds] maxAspectRatio === 1.86//差异点在这里,maxAspectRatio非0,导致后面根据maxAspectRatio重新计算了maxActivityWidth的值,从而出现显示异常。这个值和hierarchyviewer中看到的layout width值相同
1217 01-01 17:27:44.149: D/ActivityManager(10568): [computeBounds] getConfiguration() == {1.0 ?mcc?mnc [zh_CN] ldltr sw426dp w1925dp h402dp 120dpi nrml long hdr land finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1444, 320) mAppBounds=Rect(0, 0 - 1444, 320) mWindowingMode=fullscreen mActivityType=standard} s.4}
1218 01-01 17:27:44.149: D/ActivityManager(10568): [computeBounds] isInVrUiMode(getConfiguration()) == false
1221 01-01 17:27:44.152: D/ActivityManager(10568): [computeBounds] appBounds = Rect(0, 0 - 1444, 320)
1222 01-01 17:27:44.152: D/ActivityManager(10568): [computeBounds] maxActivityWidth = 1444 maxAspectRatio = 1.86 maxActivityHeight = 320
1223 01-01 17:27:44.152: D/ActivityManager(10568): [computeBounds] maxActivityWidth = 595
暴力修改方案:直接将maxAspectRatio置为0
以上是关于Android P 横屏 部分应用宽度未占满屏幕的主要内容,如果未能解决你的问题,请参考以下文章
用android系统习惯横屏,有没有办法让输入法不更改屏幕分辨率的,举个例子就是打开应用程序不受输
我想知道怎么让android一直保持横屏状态不要一打开应用后又切换到竖屏如果是关闭设置里面的自动旋转屏幕之