Android10 Launcher3调整文件夹图标的默认布局

4 篇文章 0 订阅
3 篇文章 1 订阅

从android O开始,主界面的默认图标就是圆形的,所以文件夹图标默认显示的4个应用其实是按照圆弧排列的,之前有看到文章描述做成9宫格就可以很明显地看出来;

公司需求是默认用正方形布局,不管2个还是3个、4个应用都是用正方形布局排列

默认的布局会裁剪掉一部分,图标显示太大不美观,所以先调整下图标比例,下面记录下定制的重点

1、原生的版本是会根据文件夹内部应用数量调整缩放比例的,我们不需要这个,所以固定缩放比例

/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.launcher3.folder;

import android.graphics.drawable.Drawable;

/**
 * Manages the parameters used to draw a Folder preview item.
 */
class PreviewItemDrawingParams {
    float transX;
    float transY;
    float scale;
    float overlayAlpha;
    FolderPreviewItemAnim anim;
    public boolean hidden;
    Drawable drawable;

    //文件夹内部应用图标缩略图的缩放比例
    private final float DEFAULT_SCALE = 0.42f;

    PreviewItemDrawingParams(float transX, float transY, float scale, float overlayAlpha) {
        this.transX = transX;
        this.transY = transY;
        this.scale = DEFAULT_SCALE;//scale;
        this.overlayAlpha = overlayAlpha;
    }

    public void update(float transX, float transY, float scale) {
        // We ensure the update will not interfere with an animation on the layout params
        // If the final values differ, we cancel the animation.
        if (anim != null) {
            if (anim.finalState[1] == transX || anim.finalState[2] == transY
                    || anim.finalState[0] == scale) {
                return;
            }
            anim.cancel();
        }

        this.transX = transX;
        this.transY = transY;
        this.scale = DEFAULT_SCALE;//scale;
    }
}

。。。

com.android.launcher3.icons.IconNormalizer.java
private static final float MAX_SQUARE_AREA_FACTOR = 475.0f / 576;  //375.0f / 576;
private static final float MAX_CIRCLE_AREA_FACTOR = 480.0f / 576;  //380.0f / 576;

2、固定用4个应用的布局

com.android.launcher3.folder.ClippedFolderIconLayoutRule.java

private static final float MAX_RADIUS_DILATION = 0.01f;//0.15f;
private static final float ITEM_RADIUS_SCALE_FACTOR = 1.22f;//1.33f;

...

private void getPosition(int index, int curNumItems, float[] result) {
    /
    //modify by hwj20210904默认用4个应用的布局
    curNumItems = Math.max(curNumItems, 4/*2*/);
    ......
    
    result[0] = mAvailableSpace / 2 + (float) (radius * Math.cos(theta) / 2) - halfIconSize + 5/*矫正居中参数*/;
    result[1] = mAvailableSpace / 2 + (float) (- radius * Math.sin(theta) / 2) - halfIconSize + 5;
    }

3、调整文件夹的圆角

res里面的xml有个ford_shapes.xml的文件定义

<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright (C) 2019 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<shapes xmlns:launcher="http://schemas.android.com/apk/res-auto" >

    <Circle launcher:folderIconRadius="9" />

    <!-- Default icon for AOSP -->
    <RoundedSquare launcher:folderIconRadius="0.5" />

    <!-- Rounded icon from RRO -->
    <RoundedSquare launcher:folderIconRadius="0.7" />

    <!-- Square icon -->
    <RoundedSquare launcher:folderIconRadius="0.5" />

    <TearDrop launcher:folderIconRadius="0.7" />
    <Squircle launcher:folderIconRadius="0.7" />

</shapes>

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在Android Launcher3中添加文件夹是一项非常简单的任务。首先,您需要确保您的设备装有最新版本的Android Launcher3。然后,按照以下步骤操作: 1. 在您要添加文件夹的主屏幕上,长按应用程序图标并将其拖放到主屏幕上的任何空白区域。 2. 继续将其他应用程序拖放到同一个空白区域。您将看到这些应用程序自动聚合成一个名为“文件夹”的小图标。 3. 现在,单击文件夹并将其重命名为您想要的名称(例如“工具”或“社交媒体”)。 4. 现在,您可以轻触文件夹图标以展开它,并查看其中包含的所有应用程序。您还可以将其他应用程序拖放到文件夹中,或从中删除应用程序。 总的来说,添加文件夹是一个简单,快速的过程,您可以将多个应用程序组织在一起,以增加您的生产力和效率。 ### 回答2: Android Launcher3Android系统中的一个默认桌面应用程序,它提供了许多功能和自定义选项,用户可以根据自己的需求进行个性化配置。 添加文件夹Launcher3中的一个比较简单的操作,步骤如下: 1.长按桌面上的任何一个程序图标或者小部件,直到屏幕上出现菜单。 2.将程序图标或小部件拖到菜单上的“新建文件夹”选项。 3.在弹出的窗口中,输入文件夹的名称,例如“游戏”。 4.点击确定按钮,文件夹就被创建了。 5.将其他程序图标或者小部件拖到这个新建的文件夹中,这样你就可以将类似的应用程序放在一个文件夹里面,方便管理和使用。 除此之外,Launcher3还可以对文件夹进行修改和删除。如果想要修改文件夹名称,可以长按文件夹图标,然后选择重命名选项,在弹出的窗口中修改名称。如果想要删除文件夹,可以将文件夹中的所有应用程序拖出来,然后长按文件夹图标,选择删除选项即可。 总的来说,添加文件夹可以帮助我们更好地组织应用程序,避免出现杂乱无章的情况,同时也可以提高我们的使用效率。 ### 回答3: Android Launcher3 是一个开源的 Android 开源项目桌面应用,支持自定义布局、自定义主题、自定义小部件和自定义图标等等功能。其中添加文件夹功能是 Launcher3 的核心功能之一,使用起来非常方便。 添加文件夹的操作步骤如下: 第一步,长按待创建文件夹应用程序图标,就可以将其拖拽到桌面上。 第二步,将该应用程序图标放置在需要创建文件夹的位置,在放置图标的过程中会出现与其他应用程序图标合并的状态,此时可以松手。 第三步,创建完成后,系统会自动弹出文件夹编辑界面,可以对文件夹进行命名修改。 第四步,在文件夹添加应用程序,将所有的应用程序图标全部添加到该文件夹中,避免让桌面太过臃肿。 需要注意的是,Android Launcher3 添加文件夹的功能并不是特别高级,仅能实现简单的文件夹管理,如果需要更加高级的文件夹管理功能,建议使用第三方应用程序或更高级的启动器。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值