Android 21天学习之四

活动地址:CSDN21天学习挑战赛

学习日记

1,学习博文

《Android 10.0 导航栏横屏固定在底部显示的修改》:Android 10.0 导航栏横屏固定在底部显示的修改_安卓兼职framework应用工程师的博客-CSDN博客

2,知识点

        1)导航栏布局:Android在切换横屏时导航栏会显示在右侧,通过作者的分析,可以发现在横屏情况下,是否移动到右侧显示是由属性config_navBarCanMove控制的,所以只需要修改配置文件framework/base/core/res/res/values/config.xml即可。

3, 学习收获

        通过作者的分享可以发现有很多的功能其实Android都有提供相应的配置文件,只需简单修改相应的参数配置值就可以轻松实现某种变动。当然,具体的现实原理和逻辑还需要细细分析源代码,多看和多分析才能使别人的变成自己掌握的。

4, 实操

        在切换横屏的时候发现不仅导航栏移到右侧显示,Launcher3的快捷菜单也移到了右侧。所以猜想其原理和导航栏应该类似,跟进源码看下,果然发现可以通过配置文件的属性控制其显示布局。

源码路径:packages/apps/Launcher3/src/com/android/launcher3/DeviceProfile.java

/**
     * When {@code true}, the device is in landscape mode and the hotseat is on the right column.
     * When {@code false}, either device is in portrait mode or the device is in landscape mode and
     * the hotseat is on the bottom row.
     */
    public boolean isVerticalBarLayout() {
        return isLandscape && transposeLayoutWithOrientation;
    }

通过注释得知当isVerticalBarLayout返回true时,则快捷菜单显示在右侧;返回false时则显示在底部。isLandscape是横屏显示变量,所以当transposeLayoutWithOrientation为false时即可横屏时快捷菜单显示在底部。

跟踪transposeLayoutWithOrientation发现:

// Some more constants
        transposeLayoutWithOrientation =
                res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);

所以最后只要将hotseat_transpose_layout_with_orientation的配置值改为false就使得launcher3的快捷菜单固定在底部显示。

diff --git a/packages/apps/Launcher3/res/values/config.xml b/packages/apps/Launcher3/res/values/config.xml
old mode 100644
new mode 100755
index f2d6c21816..99b581ce1e
--- a/packages/apps/Launcher3/res/values/config.xml
+++ b/packages/apps/Launcher3/res/values/config.xml
@@ -74,7 +74,7 @@
     <integer name="config_caretAnimationDuration">200</integer>
 
 <!-- Hotseat -->
-    <bool name="hotseat_transpose_layout_with_orientation">true</bool>
+    <bool name="hotseat_transpose_layout_with_orientation">false</bool>
 
     <!-- Name of a subclass of com.android.launcher3.AppFilter used to
          filter the activities shown in the launcher. Can be empty. -->

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值