Android 12 Launcher Icon 去掉白边

frameworks/libs/systemui/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java

    private Drawable normalizeAndWrapToAdaptiveIcon(@NonNull Drawable icon,
            boolean shrinkNonAdaptiveIcons, RectF outIconBounds, float[] outScale) {
        if (icon == null) {
            return null;
        }
        float scale = 1f;

        /*if (shrinkNonAdaptiveIcons && ATLEAST_OREO) {
            if (mWrapperIcon == null) {
                mWrapperIcon = mContext.getDrawable(R.drawable.adaptive_icon_drawable_wrapper)
                        .mutate();
            }
            AdaptiveIconDrawable dr = (AdaptiveIconDrawable) mWrapperIcon;
            dr.setBounds(0, 0, 1, 1);
            boolean[] outShape = new boolean[1];
            scale = getNormalizer().getScale(icon, outIconBounds, dr.getIconMask(), outShape);
            if (!(icon instanceof AdaptiveIconDrawable) && !outShape[0]) {
                FixedScaleDrawable fsd = ((FixedScaleDrawable) dr.getForeground());
                fsd.setDrawable(icon);
                fsd.setScale(scale);
                icon = dr;
                scale = getNormalizer().getScale(icon, outIconBounds, null, null);

                ((ColorDrawable) dr.getBackground()).setColor(mWrapperBackgroundColor);
            }
        } else {
            scale = getNormalizer().getScale(icon, outIconBounds, null, null);
        }*/
        scale = getNormalizer().getScale(icon, outIconBounds, null, null);
        outScale[0] = scale;
        return icon;
    }

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
如果你想在 Android 10 中的启动器图标上添加圆角,可以使用以下步骤: 1. 首先,在你的 `drawable` 文件夹中创建一个新的图标资源文件,并命名为 `ic_launcher_round.xml`。 2. 在文件中添加以下代码: ```xml <?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/ic_launcher_background"/> <foreground android:drawable="@drawable/ic_launcher_foreground"/> </adaptive-icon> ``` 这段代码定义了一个自适应图标,并将背景设置为 `ic_launcher_background` 资源文件中的颜色,将前景设置为 `ic_launcher_foreground` 资源文件中的图标。 3. 接下来,在 `values` 文件夹中的 `styles.xml` 文件中添加以下代码: ```xml <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:roundIcon">@drawable/ic_launcher_round</item> </style> ``` 这段代码将你的应用程序主题与新的启动器图标关联起来。 4. 最后,在 `AndroidManifest.xml` 文件中的 `application` 标签中添加以下代码: ```xml <application ... android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round"> ... </application> ``` 这段代码将应用程序的默认图标设置为 `ic_launcher` 资源文件中的图标,并将圆角图标设置为 `ic_launcher_round` 资源文件中的图标。 完成这些步骤后,你的应用程序的启动器图标应该具有圆角效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值