I'm trying to add launcher icon for my android application with adaptive icon features. The problem I'm facing that the icon works perfectly with android Oreo but it show android default android icon for pre Oreo devices.
How to set launcher icon according to different android versions?
Manifest code for icon :
android:icon="#mipmap/ic_launcher"
android:roundIcon="#drawable/ic_logo"
ic_launcher.xml
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#mipmap/ic_background"/>
<foreground android:drawable="#mipmap/ic_foreground"/>
</adaptive-icon>
You can create adaptive icons in Android Studio like this
Right Click on app > New --> Image Asset
And this
You can choose your image, foreground layer and background layer and all
Related
I am creating an app in Android studio. I want to change the app icon which shows when my app is opened. Please refer to the following image to understand my problem:
The icon is properly showing for my apk file and app icon. But my opened app shows the default icon.
What I done yet:
I added the app icon in my AndroidManifest.xml:
android:icon="#drawable/myappicon"
android:roundIcon="#drawable/myappicon"
I also added Go to menu File* → New → Image Assets → select launcher icon → choose image file etc
Still my opened app showing default app icon please help!
I got the solution!!
Copy icon file from file window and paste your icon file in Android Studio --> app --> res --> drawable folder!!
Go to Android Studio --> app --> res --> mipmap --> ic_launcher --> ic_launcher.xml and make changes on "myicon" place!
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#drawable/myicon"/>
<foreground android:drawable="#drawable/myicon"/>
</adaptive-icon>
Assuming this is my app icon
It works fine in Android 11 (and below)
but when I install the app in Android 12, there is a white border around the icon in the splash screen (also a black border around the top app icon.)
Is there any way I can remove those borders?
below is my splash code
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="#color/colorBlack"/>
<item>
<bitmap
android:src="#drawable/notice"/>
</item>
</layer-list>
Also this line in my AndroidManifest.xml
android:roundIcon="#drawable/notice"
There seems a misusage in your terminology splash screen. It should be called Recents screen in the screen shots.
So this is not a problem about Splash screen. This should be a problem about a launcher icon using Adaptive icon.
By default, in template projects on Android Studio, the launcher icons in the Manifest are:
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
And both of mipmaps are:
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#drawable/ic_launcher_background" />
<foreground android:drawable="#drawable/ic_launcher_foreground" />
</adaptive-icon>
Lastly, both of these ic_launcher_foreground and ic_launcher_background are vector drawables. (note that you can also use #color instead of a vector drawable)
As you can notice, layer-list or bitmap is not used. You can use an Adaptive icon on API-26+.
Here's the code in launch_background.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#android:color/black" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/applogo" />
</item>
</layer-list>
I have changed the color to 'black'- yet I get a white splash screen, neither do the logo shows up.
I have placed the logo (png) in the drawable folder. Can anyone help me with this?
first, you need 2 files to make this work, first are the files in the drawable and drawable-v21 folders they should have
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/background_color" />
<item>
<bitmap android:gravity="center" android:src="#mipmap/launch_icon" />
</item>
</layer-list>
#color/background_color
is a custom color style for android which you would have to create it next
#mipmap/launch_icon
is a custom icon image you have in your mipmap folders you can create the sizes by using https://appicon.co
and the second file will create as a colors.xml in the values and values-night folder this file will carry the color you want to use
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background_color">#000000</color>
</resources>
I think you want to remove the white screen at app boot time. Check This library, you can use color or logo image anything else instead of the white screen.
Click this Link
Here is the Preview
for android
open launch_background.xml file inside the Res folder and add one new splash screen image in the drawable folder. Now change code in two places. See tutorial example here
Edit this launch_background.xml by adding a new item and set the splash screen image as an item value.
For iOS app
Open flutter project on Xcode for Adding splash screen to flutter ios app. To open the iOS module on Xcode, open android studio and on the top menu select tools. Go to flutter –> open ios module on Xcode.
On Xcode window, Click on Runner-> Runner -> Assets.xcassets folder. Here you can see LaunchImage paste your splash screen image with all three different dimensions in this folder.
Open LaunchScreen.storyboard
Again on the left side menu just below the Assets.xcassets folder, you will see LaunchScreen.Storyboard. Click on view controller scene -> view controller -> view. Note: – select (click on ) view only don’t click on LaunchImage. You already paste the new splash screen in the LaunchImage folder in the previous step. So you will see the same new image here in this window. When you select (click on ) view then on the right side window you can see options to change view settings like content mode, background, alpha etc. change the background colour as you want and set content mode to scale to fill.
Adjust Splash Screen
You can adjust the splash screen position, size & background colour on the same window. Just click on launchImage OR select the image on the preview window. You can resize the image and can adjust the image position. On the Right side window, you can make another set as well.
iOS App Splash Screen is Ready.
Now flutter white splash screen problem has been resolved successfully for both android and iOS. You can change the flutter splash screen background color as per your requirements.
I have created a rounded icon for my app with name ic_launcher.png. I read that I must have ic_launcher_round.png too.
Why do I need that as my icon is already rounded. Will removing that cause any problem ? Can I remove this line also from andrid_manifest.xml ?
android:roundIcon="#mipmap/ic_launcher_round"
After Android 8.0 (API level 26) you can use adaptive launcher icons.
To add an adaptive icon to an app using XML, begin by updating the android:icon attribute in your app manifest to specify a drawable resource. You can also define an icon drawable resource using the android:roundIcon attribute. You must only use the android:roundIcon attribute if you require a different icon asset for circular masks.
You can also define the background and foreground drawables as elements by enclosing them in and elements.
A simple way to generate a adaptive icons is in Android Studio.
Select App folder -> right click -> New -> Image Asset
Sample Image
Sample Icon
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#drawable/ic_launcher_background" />
<foreground android:drawable="#drawable/ic_launcher_foreground" />
</adaptive-icon>
You might be thinking this question is a duplicate of this one. But since then, Android Studio has been updated and the solution given there is not working anymore.
Why are we forced to have a background when creating an Image Asset? What's the reason behind this? How we are supposed to change the launcher_icon without having any background? I don't see any option to disable the background in Image Asset.
Alternatively, I use an empty background but this doesn't work in Full Bleed Layers:
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
</vector>
Or, just remove the background, but this will add a white background in your launcher_icon:
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Remove the background here and leave the foreground -->
<foreground android:drawable="#drawable/ic_launcher_foreground"/>
</adaptive-icon>
Or, change icon type into Legacy Only and set shape to none:
Still, there's a white background in the launcher icon when installed.
So how can I get a transparent background or none for that matter, for my Launcher icon using Image Asset?
It is not a problem of the icon you created with Android Studio, but it's a problem related to your specific device you're testing the application on.
In fact, in the Image Asset if you specify the Shape to None, you get a trasparent background.
To address your problem, please try to use a different Home theme, like the Nova Launcher; you can change the home theme in Settings - Home.