【发布时间】:2019-12-13 06:17:15
【问题描述】:
在 Android Studio 中,我的应用程序图标未显示在模拟器的主屏幕或设备上。
我已经搜索了 stackoverflow 的解决方案并尝试了我发现的所有内容:我创建了图像资源,并且 ic_launcher 文件位于所有 mipmap 文件夹中(适用于各种分辨率)。我尝试清洁和重建。我尝试了不同的模拟器,并删除了模拟器然后重新安装它们。当我单击“最近”按钮并最小化时,它确实(通常)显示在应用程序的顶部。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.example">
<uses-permission android:name="android.permission.INTERNET" />
<permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.company.example.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.company.example.ViewListContents"></activity>
<activity android:name="com.company.example.AboutUs"></activity>
</application>
</manifest>
这是我的 XML ic_launcher 文件:
ic_launcher.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="@mipmap/ic_launcher_foreground"/> </adaptive-icon>
ic_launcher_round.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="@mipmap/ic_launcher_foreground"/> </adaptive-icon>
和 ic_launcher_foreground 文件: ic_launcher_foreground file
【问题讨论】:
-
请分享ic_launcher.xml和ic_launcher_round.xml的代码示例
-
这里是:ic_launcher.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="@mipmap/ic_launcher_foreground"/> </adaptive-icon> -
ic_launcher_round.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="@mipmap/ic_launcher_foreground"/> </adaptive-icon> -
请使用 xml 更新您的帖子,而不是将它们作为 cmets 发布。分享您的@mipmap/ic_launcher_foreground 也可能会有所帮助:)
-
@oemel09 啊,好的。编辑了帖子。
标签: android android-studio appicon