去除Launcher默认的google search bar后,发现桌面上面的空白区域比较大,减小桌面空白区域

去除Launcher默认的google search bar后,发现桌面上面的空白区域比较大(即下图红框框出来的区域)修改padding距离已减少空白区域
请调整DeviceProfile.java的layout(Launcher launcher)方法中Workspace的位置,尽量往上调,即修改如下的代码:
packages/apps/Launcher3/src/com/android/launcher3/DeviceProfile.java
去除Launcher默认的google search bar后,发现桌面上面的空白区域比较大,减小桌面空白区域_第1张图片

packages/apps/Launcher3/src/com/android/launcher3/DeviceProfile.java


 public void layout(Launcher launcher) {
        ...
        // Layout the workspace
        PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace);
        lp = (FrameLayout.LayoutParams) workspace.getLayoutParams();
        lp.gravity = Gravity.CENTER;
        Rect padding = getWorkspacePadding(isLayoutRtl);
        workspace.setLayoutParams(lp);
        /*workspace.setPadding(padding.left, padding.top, padding.right, padding.bottom);*/
        workspace.setPadding(padding.left/4, padding.top/4, padding.right/4, padding.bottom);//modify by kamari
        workspace.setPageSpacing(getWorkspacePageSpacing(isLayoutRtl));

        // Layout the hotseat
        View hotseat = launcher.findViewById(R.id.hotseat);
        lp = (FrameLayout.LayoutParams) hotseat.getLayoutParams();
        // We want the edges of the hotseat to line up with the edges of the workspace, but the
        // icons in the hotseat are a different size, and so don't line up perfectly. To account for
        // this, we pad the left and right of the hotseat with half of the difference of a workspace
        // cell vs a hotseat cell.
        float workspaceCellWidth = (float) getCurrentWidth() / inv.numColumns;
        float hotseatCellWidth = (float) getCurrentWidth() / inv.numHotseatIcons;
        int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
        if (hasVerticalBarLayout) {
            // Vertical hotseat -- The hotseat is fixed in the layout to be on the right of the
            //                     screen regardless of RTL
            lp.gravity = Gravity.RIGHT;
            lp.width = normalHotseatBarHeightPx;
            lp.height = LayoutParams.MATCH_PARENT;
            hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx);
        } else if (isTablet) {
            // Pad the hotseat with the workspace padding calculated above
            lp.gravity = Gravity.BOTTOM;
            lp.width = LayoutParams.MATCH_PARENT;
            lp.height = hotseatBarHeightPx;
            hotseat.findViewById(R.id.layout).setPadding(
                    /*hotseatAdjustment + padding.left, 0,
                    hotseatAdjustment + padding.right, 2 * edgeMarginPx);*/
                    hotseatAdjustment + padding.left/2, 0,
                    hotseatAdjustment + padding.right/2, 2 * edgeMarginPx);//modify by kamari
        } else {
            // For phones, layout the hotseat without any bottom margin
            // to ensure that we have space for the folders
            lp.gravity = Gravity.BOTTOM;
            lp.width = LayoutParams.MATCH_PARENT;
            lp.height = hotseatBarHeightPx;
            hotseat.findViewById(R.id.layout).setPadding(
                    hotseatAdjustment + padding.left, 0,
                    hotseatAdjustment + padding.right, 0);
        }
        hotseat.setLayoutParams(lp);
}

你可能感兴趣的:(MTK笔记)