Android 12 Launcher3 去掉Hotseat

news/2024/12/21 21:28:39/

1.概述


   在12.0 产品定制化开发中 由产品需求Launcher3 页面布局的原因,要求Launcher3 需要去掉Hotseat 不显示Hotseat下面几个图标,而做满屏app的显示,从而达到美观的效果,下面就来分析去掉Hotseat从而实现这个功能

2.Launcher3 去掉Hotseat的核心类

packages/apps/Launcher3/res/layout/launcher.xml
packages/apps/Launcher3/src/com/android/launcher3/DeviceProfile.java

3.Launcher3 去掉Hotseat的核心功能分析和实现

        在Launcher3中主页面就是launcher.xml只布局,hotseat布局也在这里面,所以隐藏hotseat可以从这里先看launcher.xml的布局。
首先看下launcher.xml的布局

3.1 launcher.xml  hotseat布局

<com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:id="@+id/launcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.android.launcher3.dragndrop.DragLayerandroid:id="@+id/drag_layer"android:layout_width="match_parent"android:layout_height="match_parent"android:clipChildren="false"android:clipToPadding="false"android:importantForAccessibility="no"><!-- The workspace contains 5 screens of cells --><!-- DO NOT CHANGE THE ID --><com.android.launcher3.Workspaceandroid:id="@+id/workspace"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_gravity="center"android:theme="@style/HomeScreenElementTheme"launcher:pageIndicator="@+id/page_indicator" /><include layout="@layout/memoryinfo_ext" /><!-- DO NOT CHANGE THE ID --><includeandroid:id="@+id/hotseat"layout="@layout/hotseat" /><includeandroid:id="@+id/overview_panel"layout="@layout/overview_panel"android:visibility="gone" /><!-- Keep these behind the workspace so that they are not visible whenwe go into AllApps --><com.sprd.ext.pageindicators.WorkspacePageIndicatorLineandroid:id="@+id/page_indicator"android:layout_width="match_parent"android:layout_height="@dimen/vertical_drag_handle_size"android:layout_gravity="bottom"android:theme="@style/HomeScreenElementTheme" /><includeandroid:id="@+id/page_indicator_customize"layout="@layout/page_indicator_customize" /><includeandroid:id="@+id/drop_target_bar"layout="@layout/drop_target_bar" /><includeandroid:id="@+id/scrim_view"layout="@layout/scrim_view" /><includeandroid:id="@+id/apps_view"layout="@layout/all_apps"android:layout_width="match_parent"android:layout_height="match_parent" /></com.android.launcher3.dragndrop.DragLayer></com.android.launcher3.LauncherRootView>

从布局中可以看到android:id="@+id/hotseat"就是hotseat布局,所以隐藏hotseat就是需要设置属性为gone。

<includeandroid:id="@+id/hotseat"layout="@layout/hotseat"android:visibility="gone" />

3.2 DeviceProfile.java 关于hotseat高度的修改

public DeviceProfile(Context context, InvariantDeviceProfile inv,
Point minSize, Point maxSize,
int width, int height, boolean isLandscape, boolean isMultiWindowMode) {this.inv = inv;this.isLandscape = isLandscape;this.isMultiWindowMode = isMultiWindowMode;// Determine sizes.widthPx = width;heightPx = height;if (isLandscape) {availableWidthPx = maxSize.x;availableHeightPx = minSize.y;} else {availableWidthPx = minSize.x;availableHeightPx = maxSize.y;}Resources res = context.getResources();DisplayMetrics dm = res.getDisplayMetrics();// Constants from resourcesisTablet = res.getBoolean(R.bool.is_tablet);isLargeTablet = res.getBoolean(R.bool.is_large_tablet);isPhone = !isTablet && !isLargeTablet;aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;// Some more constantstransposeLayoutWithOrientation =res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);context = getContext(context, isVerticalBarLayout()? Configuration.ORIENTATION_LANDSCAPE: Configuration.ORIENTATION_PORTRAIT);res = context.getResources();edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);desiredWorkspaceLeftRightMarginPx = isVerticalBarLayout() ? 0 : edgeMarginPx;int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;int cellLayoutPadding = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding);if (isLandscape) {cellLayoutPaddingLeftRightPx = 0;cellLayoutBottomPaddingPx = cellLayoutPadding;} else {cellLayoutPaddingLeftRightPx = cellLayoutPaddingLeftRightMultiplier * cellLayoutPadding;cellLayoutBottomPaddingPx = 0;}verticalDragHandleSizePx = res.getDimensionPixelSize(R.dimen.vertical_drag_handle_size);verticalDragHandleOverlapWorkspace =res.getDimensionPixelSize(R.dimen.vertical_drag_handle_overlap_workspace);IconLabelController ilc = LauncherAppMonitor.getInstance(context).getIconLabelController();maxIconLabelLines = ilc != null ?ilc.getIconLabelLine() : IconLabelController.MIN_ICON_LABEL_LINE;iconDrawablePaddingOriginalPx =res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);workspaceSpringLoadedBottomSpace =res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);workspaceCellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x);hotseatBarTopPaddingPx =res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);hotseatBarBottomPaddingPx = (isTallDevice ? 0: res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_non_tall_padding))+ res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);hotseatBarSidePaddingEndPx =res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);// Add a bit of space between nav bar and hotseat in vertical bar layout.hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? verticalDragHandleSizePx : 0;hotseatBarSizePx = ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx): (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx));....}

在DeviceProile构造函数中的hotseatBarSizePx 就是设置的导航栏高度,在这里构建hotseat布局的时候,可以通过设置这个高度了布后hotseatBarSizePx就是hotseat的高度
直接设为0即可
修改如下:

hotseatBarSizePx = 0/*ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx): (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx))*/;


http://www.ppmy.cn/news/1527362.html

相关文章

数据结构基础讲解(八)——树和二叉树专项练习(上)

本文数据结构讲解参考书目&#xff1a; 通过网盘分享的文件&#xff1a;数据结构 C语言版.pdf 链接: https://pan.baidu.com/s/159y_QTbXqpMhNCNP_Fls9g?pwdze8e 提取码: ze8e 数据结构基础讲解&#xff08;七&#xff09;——数组和广义表专项练习-CSDN博客 个人主页&#x…

如何在AWS账户上进行充值:一份详尽指南

大家好&#xff0c;小编今天给大家带来一份关于如何在AWS账户上进行充值的详尽指南。对于使用AWS服务的用户来说&#xff0c;保持账户余额充足是确保服务不中断的关键。下面&#xff0c;九河云将详细讲解具体的操作步骤。 步骤一&#xff1a;登录AWS管理控制台 首先&#xff…

Qt学习之旅 I

构建一个跨平台的应用(Create A Cross-Platform Application) 目录 构建一个跨平台的应用(Create A Cross-Platform Application) 设计模式 开始构建 Qt是跨平台的C框架&#xff0c;这里&#xff0c;我们将会构建一个简单的C跨平台项目来熟悉QT是如何实现简单的跨平台的。 …

JUnit 5 详解

JUnit 5 详解 JUnit 是 Java 生态系统中最流行的测试框架之一&#xff0c;用于编写单元测试、集成测试等。JUnit 5 是其最新版本&#xff0c;提供了更多功能和灵活性&#xff0c;旨在提高测试的可读性、可维护性和可扩展性。JUnit 5 在设计上有别于之前的版本&#xff0c;并引…

【Kubernetes】常见面试题汇总(十一)

目录 33.简述 Kubernetes 外部如何访问集群内的服务&#xff1f; 34.简述 Kubernetes ingress &#xff1f; 35.简述 Kubernetes 镜像的下载策略&#xff1f; 33.简述 Kubernetes 外部如何访问集群内的服务&#xff1f; &#xff08;1&#xff09;对于 Kubernetes&#xff0…

计算机毕业设计选题推荐-养老院管理系统-Java/Python项目实战

✨作者主页&#xff1a;IT毕设梦工厂✨ 个人简介&#xff1a;曾从事计算机专业培训教学&#xff0c;擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。 ☑文末获取源码☑ 精彩专栏推荐⬇⬇⬇ Java项目 Py…

Clickhouse如何完全保证数据的去重

在ClickHouse中&#xff0c;实现数据去重是为了避免在大规模分布式环境中数据的重复存储和计算&#xff0c;这对于保持数据的一致性和准确性非常重要。ClickHouse可以通过多种机制确保数据的去重&#xff0c;从数据表结构、插入去重、数据合并去重、查询去重等多个方面入手&…

el-table使用合计和固定列时,滚动条被覆盖区域无法拖拽问题

pointer-events文档 解决思路为通过pointer-events实现事件穿透&#xff0c;不响应固定列的拖拽&#xff0c;而是响应其子元素的拖拽事件 /deep/.el-table__fixed, /deep/.el-table__fixed-right {pointer-events: none; } /deep/.el-table__fixed *, /deep/.el-table__fixed-…