目录

android13修改系统Launcher不跟随重力感应旋转

android13系统中需要修改系统原生Launcher不跟随重力感应旋转。

通过代码查找发现packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java中存在一个函数getAllowRotationDefaultValue,用于获取是否允许旋转的默认值。

java 复制代码
    public static boolean getAllowRotationDefaultValue(DisplayController.Info info) {
        // If the device's pixel density was scaled (usually via settings for A11y), use the
        // original dimensions to determine if rotation is allowed of not.
        float originalSmallestWidth = dpiFromPx(Math.min(info.currentSize.x, info.currentSize.y),
                DENSITY_DEVICE_STABLE);
        return originalSmallestWidth >= MIN_TABLET_WIDTH;
    }

这个函数主要根据屏幕dpi和尺寸来决定是否允许Luancher允许旋转。如果要禁止旋转直接返回false即可。

本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
前行的小黑炭1 小时前
设计模式:为什么使用模板设计模式(不相同的步骤进行抽取,使用不同的子类实现)减少重复代码,让代码更好维护。
android·java·kotlin
ufo00l2 小时前
2025年了,Rxjava解决的用户痛点,是否kotlin协程也能解决,他们各有什么优缺点?
android
古鸽100862 小时前
libutils android::Thread 介绍
android
_一条咸鱼_2 小时前
Android Compose 框架性能分析深度解析(五十七)
android
BrookL2 小时前
Android面试笔记-kotlin相关
android·面试
QING6185 小时前
Kotlin Delegates.notNull用法及代码示例
android·kotlin·源码阅读
QING6185 小时前
Kotlin filterNot用法及代码示例
android·kotlin·源码阅读
张风捷特烈20 小时前
Flutter 伪3D绘制#03 | 轴测投影原理分析
android·flutter·canvas
omegayy1 天前
Unity 2022.3.x部分Android设备播放视频黑屏问题
android·unity·视频播放·黑屏
mingqian_chu1 天前
ubuntu中使用安卓模拟器
android·linux·ubuntu