从Android O开始,应用程序可以拥有自适应图标,即2层可绘图:前景和背景.背景是一个掩码,它可以成为启动器/用户选择的形状,而OS也有一个默认的形状.
以下是Nova Launcher允许执行的示例:
正如您所看到的,它不仅可以选择使用哪种形状,还可以避免形状(在"更喜欢的旧图标"中).
以下是一些关于它的链接:
虽然我知道如何创建一个AdaptiveIconDrawable实例,并且我知道有助于为当前应用程序创建一个实例的向导,但我不知道如果给定一个AdaptiveIconDrawable实例,启动器会改变形状.
不仅如此,我记得我看到一个或两个发射器不允许任何形状.
遗憾的是,我无法找到有关此部分的任何信息,可能是因为这是一个相对非常新的功能.StackOverflow上甚至没有关键字.
我尝试阅读自适应图标,但无法找到对接收方的引用.
我知道它里面有2个drawable:
我知道,至少,如何从第三方应用程序中获取AdaptiveIconDrawable实例(假设它有一个):
PackageManager pm = context.getPackageManager();
Intent launchIntentForPackage = pm.getLaunchIntentForPackage(packageName);
String fullPathToActivity = launchIntentForPackage.getComponent().getClassName();
ActivityInfo activityInfo = pm.getActivityInfo(new ComponentName(packageName, fullPathToActivity), 0);
int iconRes = activityInfo.icon;
Drawable drawable = pm.getDrawable(packageName, iconRes, activityInfo.applicationInfo); // will be AdaptiveIconDrawable, if the app has it
Run Code Online (Sandbox Code Playgroud)
给定一个AdaptiveIconDrawable实例,如何将其塑造成圆形,矩形,圆角矩形,撕裂等?
如何删除形状并仍然具有图标的有效大小(使用其中的前景可绘制)?发射器的应用程序图标的官方大小为48 dp,而AdaptiveIconDrawable内部drawable的官方大小为72dp(前景),108dp(背景).我想这意味着将前景绘制,以某种方式调整大小,并转换为位图.
在哪种情况下使用它确实有用IconCompat.createWithAdaptiveBitmap()?有人写道:"如果您使用Bitmap构建动态快捷方式,您可能会发现支持库26.0.0-beta2的IconCompat.createWithAdaptiveBitmap()可用于确保正确屏蔽您的位图以匹配其他自适应图标." ,但我不知道哪些情况对它有用.
编辑:为了从自适应图标的前景部分创建一个位图,同时调整到适当的大小,我认为这可能是一个很好的解决方案:
val foregroundBitmap = convertDrawableToBitmap(drawable.foreground)
val targetSize = convertDpToPixels(this, ...).toInt()
val scaledBitmap = …Run Code Online (Sandbox Code Playgroud) 我的Android应用程序在Android oreo版本的白色圆圈内显示启动器图标.
我想显示启动器图标,因为它默认情况下就像在oreo设备上的方形.
通过各种博客发现并发现:
1)移动用户可以从主屏幕设置屏幕改变图标类型
(但我不想要.我想默认只显示方块)
2)使用26以下的应用程序目标sdk版本
(我希望有最新的sdk版本定位和方形启动器图标)
我试过了 :
任何人都可以帮我解决同样的问题吗?
icons geometry android-launcher android-8.0-oreo adaptive-icon
如何在Android 8.0及更高版本上为我的Flutter应用程序使用自适应图标?Android Studio中的"创建图像资源"对话框显示"项目必须使用SDK 26或更高版本构建才能使用自适应图标",即使我的android build.gradle已将CompileSDKVersion设置为27.如果我在XML中定义图标,则不会工作,它似乎只是使用常规遗留应用程序图标.
刚刚从Android Studio 3.2.1升级到3.3.以前我的项目 - 目标SDK v28- 构建没有问题,现在我得到此构建错误:
- 出了什么问题:任务':app:processDebugResources'执行失败.
Android资源链接失败C:\ app\src\main\res\mipmap-anydpi-v25\ic_launcher_round.xml:错误:<adaptive-icon>元素需要至少26的sdk版本.
错误:链接文件资源失败.
显然,我<adaptive-icon>在该mipmap-anydpi-v25文件夹中有一个资源.
那么,哪个AS版本正确处理这个问题; 3.2.1还是3.3?我应该删除我的v25图标吗?我认为Lollipop支持这种类型的图标......
首先
我注意到在 Android Studio 中创建一个新项目时它会生成drawable-v24带有ic_launcher_foreground.xml图标的文件夹。
我的问题是:
drawable-v24放在drawable-v21文件夹中而不是放在文件夹中?其次
另一个生成的资产是ic_launcher_background.xml在res/drawable文件夹中创建的,后来从mipmap-anydpi-v26/ic_launcher.xml.
res/drawable文件夹中创建而不是在res/drawable-v24或 中res/drawable-v26?是由于 mipmap 文件夹的某些性质吗?icons android android-studio android-vectordrawable adaptive-icon
实际上,我正在开发一个 Android 应用程序。问题是关于在 VectorDrawables 中导出带有渐变的图标。我使用 Adobe Illustrator 绘制我的图标并将它们导出到 Android Studio 的 Asset Studio。
根据 Material Design 指南,对象的阴影应该是径向渐变渐变,其中第一个滑块位于 32% 的位置,不透明度为 15%。第二个滑块位于 62% 的位置,不透明度为 2%。最后一个滑块为 100% 全透明颜色,45° 角
我在 Adobe Illustrator 中创建了图标,看起来很完美,并且按照材料设计遵循所有内容。但是当我将它们导出到 Android Studio 时,图像被严重改变,因为 Vector Drawables 还不完全支持渐变。Android 7.0 + 设备支持 VectorDrawables 中的渐变。另一个问题是谷歌说高程物体应该显示 45°(基于梯度)的长阴影。但另一方面,它们并不完全支持渐变。如何将渐变应用程序图标扩展到低于 7.0.0 的设备?
Ps 我导出 Illustrator 文件以支持自适应图标。请有人指导我在 VectorDrawables 中实现渐变阴影,使它们看起来类似于旧图标
icons android adobe-illustrator android-vectordrawable adaptive-icon
尝试在config.xml中添加自适应图标时,尝试构建时出现以下错误
设置以下属性之一,但密度类型缺少其他属性:ldpi,mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi。请确保定义了所有require属性。
我的代码是:
<platform name="android">
<resource-file src="res/icon/android/colors.xml" target="/app/src/main/res/values/colors.xml" />
<icon background="@color/background" density="ldpi" foreground="res/icon/android/ldpi-foreground.png" />
<icon background="@color/background" density="mdpi" foreground="res/icon/android/mdpi-foreground.png" />
<icon background="@color/background" density="hdpi" foreground="res/icon/android/hdpi-foreground.png" />
<icon background="@color/background" density="xhdpi" foreground="res/icon/android/xhdpi-foreground.png" />
<icon background="@color/background" density="xxhdpi" foreground="res/icon/android/xxhdpi-foreground.png" />
<icon background="@color/background" density="xxxhdpi" foreground="res/icon/android/xxxhdpi-foreground.png" />
</platform>
Run Code Online (Sandbox Code Playgroud)
我正在使用cordova-android 8.0.0
最近我开始为 android 应用程序创建自适应图标
已成功导入 ic_launcher_background.xml 的 SVG 文件,但对于 ic_launcher_foreground.xml 出现如下错误
注意:我无法发布完整代码,所以我删除了路径数据
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group>
<clip-path android:pathData="M0 0H108V108H0V0Z" />
<path
android:fillColor="#00000000"
android:pathData="M0 0H108V108H0V0Z" />
<group
android:translateX="54.5"
android:translateY="52.5">
<path
android:fillColor="#FFE600"
android:pathData="M-16.06429 -19.14453L-16.06429 -1.557617L-12.76498 -1.217773L-12.76498 0L-23.44173 0L-23.44173 -1.217773L-20.15658 -1.557617L-20.15658 -15.87354L-23.42757 -14.79736L-23.42757 -16.00098L-18.07504 -19.14453L-16.06429 -19.14453ZM2.131508 -9.572266L2.131508 -9.572266Q2.131508 0.2832031 -4.098961 0.2832031L-4.098961 0.2832031Q-7.100914 0.2832031 -8.630211 -2.237305Q-10.15951 -4.757813 -10.15951 -9.572266L-10.15951 -9.572266Q-10.15951 -14.2876 -8.630211 -16.78687Q-7.100914 -19.28613 -3.98568 -19.28613L-3.98568 -19.28613Q-0.9837266 -19.28613 0.5738906 -16.81519Q2.131508 -14.34424 2.131508 -9.572266ZM-2.017418 …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 React Native Android 中使用自适应图标,但它产生以下错误。
AAPT:错误:在以下位置找到意外元素
这是我的 manifes.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.anar">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.VIBRATE" />
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme">
<activity android:screenOrientation="portrait" android:launchMode="singleTop" android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value="MY_API_KEY_IS_HIDDEN"/>
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
</application>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" /> </adaptive-icon>
</manifest>
Run Code Online (Sandbox Code Playgroud) 看图:
为什么我的图标看起来与屏幕上的其他图标不同?在 Android Studio 中,我将修剪设置为零,但它仍然在我的手机上显示为这样。我安装了 Nova Launcher,这使得我所有的应用程序都有圆形图标,但是看看谷歌地图和 Instagram,我如何让我的图标填满圆圈?
adaptive-icon ×11
android ×9
icons ×4
cordova ×1
flutter ×1
geometry ×1
html ×1
react-native ×1