Launcher3布局的布局配置

一、桌面布局
在这里插入图片描述
二、布局配置
1、(1)Launcher 在以下配置文件定义了不同分辨率对应的 profile 标签,基本上涵盖了大部分的分辨率情况。profile 标签路径:7731e81\sc7731e.81.az\packages\apps\Launcher3\res\xml\device_profiles.xml
其中 Go 版本的 profile 标签在 packages\apps\Launcher3\go\res\xml\device_profiles.xml。

(2)profile 标签内容
<profile
launcher:name=“Nexus 5” //配置信息名称
launcher:minWidthDps=“335”
launcher:minHeightDps=“567”
launcher:numRows=“4” //桌面应用行数
launcher:numColumns=“4” //桌面和主菜单应用列数
launcher:numFolderRows=“4” //文件夹中应用行数
launcher:numFolderColumns=“4” //文件夹中应用列数
launcher:minAllAppsPredictionColumns=“4”
launcher:iconSize=“54” //应用图标大小
launcher:iconTextSize=“13.0” //应用图标名称字体大小
launcher:numHotseatIcons=“5” //Dock 即 hotseat 应用图标数量
launcher:defaultLayoutId="@xml/default_workspace_4x4"//桌面配置文件
/>
2、确认布局配置信息
(1)定位到packages\apps\Launcher3\src\com\android\launcher3\InvariantDeviceProfile.java
(2)查找InvariantDeviceProfile(Context context) {

InvariantDeviceProfile closestProfile = closestProfiles.get(0);
if(LogUtils.DEBUG) {
LogUtils.d(“DeviceProfile”, "DeviceProfile name = " + closestProfile.name);
}

}
(3)请在 Debug 版本,通过 log 确认 DeviceProfile name 的值,即可确定当前设备使用的 profile 标签,然后根据需求进行客制化。
三、显示大小
1、在系统设置显示显示大小,可以改变手机的显示大小。每次修改显示大小后,Launcher 会重新计算当前屏幕区间,并重新适配布局配置,当由大的行列数向小的行列数变化时,Launcher 会重新计算每个图标的位置,根据算法将其放到最优的位置。因此,这种情况下会出现某些图标位置发生变化的现象。
这是 google 原生设计,属于正常现象
2、Go 版本只配置了一种 profile 标签,且图标大小、行列数是不变的,故不存在上述现象。

猜你喜欢

转载自blog.csdn.net/baidu_41672657/article/details/83383137