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)
【Android P 横屏 部分应用宽度未占满屏幕】能正常显示的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
推荐阅读
- EffectiveObjective-C2.0|EffectiveObjective-C2.0 笔记 - 第二部分
- android第三方框架(五)ButterKnife
- Android中的AES加密-下
- 带有Hilt的Android上的依赖注入
- android|android studio中ndk的使用
- 生命中最迷人的部分轻拿轻放
- Android事件传递源码分析
- RxJava|RxJava 在Android项目中的使用(一)
- Android7.0|Android7.0 第三方应用无法访问私有库
- 深入理解|深入理解 Android 9.0 Crash 机制(二)