Launcher默认支持旋转

简介: Launcher默认支持旋转

launcher界面默认开启旋转

1、默认情况

launcher默认没有开启旋转,长按桌面–》home Settings中有开关可以打开是否允许旋转

<SwitchPreference
        android:key="pref_allowRotation"
        android:title="@string/allow_rotation_title"
        android:summary="@string/allow_rotation_desc"
        android:defaultValue="@bool/allow_rotation"
        android:persistent="true" />


如果要默认打开可以修改allow_rotation值为true(无效)。

2、recent UI界面旋转异常

当默认打开旋转后,home Settings里面的选项会消失。主界面可以正常旋转;但是近期任务界面旋转显示异常。


packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java中

直接返回true

    public static boolean getAllowRotationDefaultValue(DeviceProfile deviceProfile) {
        // 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(deviceProfile.widthPx, deviceProfile.heightPx), DENSITY_DEVICE_STABLE);
        return true;
    }
public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation";
...
public static boolean getAllowRotationDefaultValue(Context context) {
    //默认支持旋转,这里直接return true
        if (context != null && context.getResources().getBoolean(R.bool.allow_rotation)){
            return true;
        }
        // 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.
        Resources res = Resources.getSystem();
        int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp
                * res.getDisplayMetrics().densityDpi / DENSITY_DEVICE_STABLE;
        return originalSmallestWidth >= 600;
    }


packages/apps/Launcher3/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java中


  private void initFlags() {
        SysUINavigationMode.Mode currentMode = SysUINavigationMode.getMode(mContext);
        boolean rotationWatcherSupported = mOrientationListener.canDetectOrientation() &&
                currentMode != TWO_BUTTONS;
        setFlag(FLAG_ROTATION_WATCHER_SUPPORTED, rotationWatcherSupported);
 
        // initialize external flags
        updateAutoRotateSetting();
        updateHomeRotationSetting();
    }
    ...
private void updateHomeRotationSetting() {
        setFlag(FLAG_HOME_ROTATION_ALLOWED_IN_PREFS,
                mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, getAllowRotationDefaultValue(mContext)));//这里默认是false
    }

保持旋转设置一致即可


目录
相关文章
|
XML Android开发 数据格式
Android CheckedTextView 使用+实例
CheckedTextView是什么 主要XML属性 在点击事件里判断状态设置状态 第一次点击无效 实例 1.主界面CheckedTextViewActivity.java 2.主布局activity_textview_ctv.xml 3.复选框Adapter 4.复选框adapter对应布局 5.单选框adapter 6.单选框adapter对应布局 7.逻辑处理从adapter放在主界面处
1159 0
Android CheckedTextView 使用+实例
|
XML 前端开发 Android开发
Android XML 布局基础(四)内外边距(margin、padding)
Android XML 布局基础(四)内外边距(margin、padding)
821 0
|
12月前
|
人工智能 自然语言处理 监控
盘点 2025 电商自动化利器:Agent 产品实力排行,降本增效不空谈
电商进入存量竞争时代,获客难、运营重、跨境壁垒高。智能Agent成破局关键,尤以融合大模型与自动化的“数字员工”为代表。实在Agent凭RPA进化基因与“一句话生成流程”能力,实现跨系统协同、全场景覆盖;瓴羊Quick Service擅全渠道客服,扛大促峰值;探迹·探域智能体轻量零配置,中小商家首选。选型需按规模、场景匹配,聚焦易用性、兼容性与数据安全,让AI真正赋能增长。
1694 8
|
XML API Android开发
码农之重学安卓:利用androidx.preference 快速创建一、二级设置菜单(demo)
本文介绍了如何使用androidx.preference库快速创建具有一级和二级菜单的Android设置界面的步骤和示例代码。
927 1
码农之重学安卓:利用androidx.preference 快速创建一、二级设置菜单(demo)
|
安全 Java Shell
Android发送广播时报错:Sending non-protected broadcast xxxxxxx from system xxxxxxxxxx
Android发送广播时报错:Sending non-protected broadcast xxxxxxx from system xxxxxxxxxx
2486 0
|
机器学习/深度学习 搜索推荐 算法
混合推荐系统
混合推荐系统
|
存储 缓存 Java
dex、vdex、.odex与.oat
dex、vdex、.odex与.oat
2247 8
|
Android开发
解決Android报错:Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
解決Android报错:Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
740 1
|
Shell Android开发
Android设置语言
Android设置语言
636 1
|
编解码 Android开发
selinux报avc denied权限和编译报neverallow 解决方案
selinux报avc denied权限和编译报neverallow 解决方案
2473 2

热门文章

最新文章