I have an app on android that create home shortcut icon.
The image of the icon is image that i set programmatically from the drawable
Now the problem is, when the shortcut was created on the home screen it's created with white background.
How do i remove that white backgroubd and set image to full size of icon?
Thank you all..
EDIT: the app i was talking about is app that i developed using android studio and just want to set full size of image when i create home shortcut
This is highly dependent on the launcher you use. The image looks like the standard google android 8+ (?) icon shape.
I theory it could be part of the icon you created but since you are asking this I doubt it.
In older versions of android the outer shape of the icons were individual, while rather cool and the outline correctly shown while dragging them etc many complained about the lack of a uniform look of all the icons in the app drawer etc.
It was introduced to make all icons seem more uniform.
Long pressing an empty space in the Google Pixel launcher for example shows a choice to go into the settings for the launcher and there you can change the shape all icons should have:
In addition to this, apps can take advantage of the various shapes and adapt to them and fill them out so to speak. See for example the Chrome icon while changing the icon shapes in the launcher settings.
Introduced in android 8: The feature is called adaptive icons.
See the docs about adaptive icons here:
https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive
That is because of adaptive icons - a feature of Android 8 and can't or shouldn't be changed. You can at best change the colour of the background.
i removed the white background from the launcher icon by following these guidelines https://developer.android.com/studio/write/image-asset-studio
a few more points
in the background layer, move the slider to resize the icon until you see no what would have been the white background.
in the manifest file, change the icons to reference the mipmap folder;
android:icon="#mipmap/yourlogo"
android:roundIcon="#mipmap/yourlogo"
Related
I just swapped my android launcher icon(just learned how). I noticed MANY icons on my android are circular and I am wondering do I have to get an image done like that OR is there way I can have the launcher put the icon(a png with transparent background) and draw a circle for the launcher somehow? (this would be easier that fooling around in some drawing tool as well).
In the app I used CircleImageView for contacts which did the circle but that was in java, and android launcher is xml so not sure if I can use CircleImageView?
You'll need to use adaptive icons instead of a single image to allow Android to adjust your icon. Essentially this is defining a background drawable and a foreground drawable, and Android will do the rest.
If you right click your res/drawable folder in Android Studio, then select New -> Image Asset, you will see the following wizard. This will let you easily create launcher icons that work in all shapes.
For further information you may find the official Android docs helpful, as well as Nick Butcher's excellent guide.
I was using the following website to generate several launcher icons for my flutter app.
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
But after I replace the original flutter icons ( file path: myapp/android/app/src/main/res ) and run my app, my icon is in a circled icon. ( check the image I attached )
My Android Virtual Device is Nexus 5X API 28.
So can anyone tell me what was wrong? And Can I use a square icon to replace this one?
The launcher that comes on the emulator forces all icons to be round. If the icon isn't already round, it will add a round border around it, like you see in that screenshot.
This isn't something you can change. If you want your icon to be square, use a different launcher. It's ultimately up to the user how their icons display.
You may want to consider implementing adaptive icons, so if a user does use circle or squircle icons and their icon pack/launcher forces all icons to be round, it at least won't look terrible.
I am trying hard to get rid of the extra margin around the ic launcher icons generated by Android Studio without luck. I know this is one of Google's material design trends. Though, the icons are so small on devices which is ugly.
I have Googled for around three hours and the only workaround I could find is to generate the clipart with a transparent background and photoshop the background with rounded corners which is pretty slow.
Is there a better solution than this?
Thank you.
Per the Designing adaptive icons blog post, the adaptive icon images created in the drawable directory for use on API 26+ devices follow the adaptive icon size and shape:
You'll note that while the entire image must be 108dp by 108dp, the actual visual area is only the center 72dp - the outer edge is only seen when dragging the icons around (where parallax effects may cause it be visible).
The Pixel Launcher, as well as many third party launchers, enforce the use of adaptive icons on API 26+ devices, so you should always design with that requirement in mind - the alternative, in the Pixel Launcher's case for instance, is to place your non-adaptive icon within a white circle.
Therefore you should always design your icon such that the background layer takes up the full size, but any foreground image you put on top of that background layer should be contained within that center area.
You can't just remove that margin without the foreground image being messed up, but as per the Implementing Adaptive Icons follow up blog post, you can remove any white excess around the foreground by putting your trimmed image within a transparent drawable of 108dp x 108dp by using an InsetDrawable.
<!-- Center a 54x54dp image in the 108x108dp size of adaptive icons -->
<inset
android:drawable="#mipmap/ic_fg_trimmed"
android:insetLeft="25%"
android:insetTop="25%"
android:insetRight="25%"
android:insetBottom="25%" />
Although this would have to be something you'd need to do to the ic_launcher_foreground image yourself after the fact.
A better solution, in most cases, is to use vector drawable images as the input to the Android Studio Image Asset wizard - this will ensure they are always the right size and don't take up any additional space in your APK.
I think i had the same problem as you. I solved this with a nasty hack, in the AndroidManifest.xml I just changed the roundIcon to point to the standard icon.
<application
…
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher"
See more from the docs.
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.
I am trying to set my app logo using image asset in android studio. This is because if I put my app logo directly in drawable or mipmap, then it causes many problems like: If it's size is big then app crash occurs, if device running on oreo then logo will not showed and default ic_launcher is showing etc.
While trying to set my app's logo using image asset, I am facing a problem:
I can't keep app logo's background transparent.
I have a png logo made in photoshop and I want to set this as my app logo and I don't want any background but android studio image asset doesn't provide any option to remove background. I tried following solutions from google:
this and this
but none of these worked for me.
Tried solutions:
By setting shape to none
by Deleting ic_launcher_background file from it's default location
Tried in different devices
None of these works...please help me. Any help will be appreciated.
Android 8.0 Oreo (API level 26) introduced adaptive launcher icons, which consist of two layers: a foreground and a background. The material design guidelines state that the background layer must be opaque in Android O and beyond, as you can see at the bottom of the following citation. So, the adaptive launcher icon for Android 8.0 or higher must have opaque background color at least, if targetSdkVersion of your app is 26 or higher.
https://material.io/guidelines/style/icons.html#icons-icons-for-android
Icons for Android
Android O and beyond
Android O icons represent your app on a device's Home and All Apps screens. The following guidelines describe how icons can receive unique visual treatments, animations, and behaviors.
...
Layer specs
Icons consist of two layers: a foreground and a background. Each layer can animate and receive treatments independently from the other layer.
Foreground (scrolling parallax)
108 x 108 dp
72dp masked section
Transparency recommended (optional)
Background (subtler parallax)
108 X 108 dp
72dp masked section
Must be opaque
Workaround for 7.1 or lower
Although launcher icons for 8.0 or higher must have opaque background color, the other legacy launcher icons for 7.1 or lower can revert to transparent background color, if you can omit round launcher icons from your app.
First, create Launcher Icons (Adaptive and Legacy). It will create adaptive launcher icons and legacy launcher icons. All of them have opaque background color, at first.
After that, create Launcher Icons (Legacy only). This will overwrite only the existing legacy launcher icons, as you can see in the second screenshot below. If you set the shape to none, they will have transparent background color.
Delete folder res/mipmap/ic_laucher_round in the project window.
Open AndroidManifest.xml and remove attribute android:roundIcon="#mipmap/ic_launcher_round" from the application element.
In the left-side pane above, the following XML files define adaptive launcher icons for Android 8.0 or higher.
mipmap-anydpi-v26/ic_launcher.xml
mipmap-anydpi-v26/ic_launcher_round.xml
As seen in the right-side pane, they refer to the following drawable XML files.
drawable/ic_launcher_background.xml
drawable-v24/ic_launcher_foreground.xml
Update #1:
In Android 8.0 or higher, the background color of launcher icons can be transparent, as shown in the Android 8.1 (Nexus 5X) screenshots. The sample app "NoAdaptive" is without any resource for the adaptive launcher icons in folder mipmap-anydpi-v26, and the other app "Adaptive" has the resource.
Update #2:
Although the background color of launcher icon can be transparent in Android 8.0 or higher, it depends on user’s launcher app. Some launcher apps will convert your legacy icon to opaque adaptive icon.
In Nexus 5X device (Android 8.1)
The default launcher app is Google Now Launcher, according to its package name com.google.android.launcher. The background color can be transparent, as in the screenshots of Update #1.
In Nexus 5 emulator (Android 8.1)
The default launcher app is Pixel Launcher, according to its package name com.google.android.apps.nexuslauncher. The background color can be transparent in Recents screen, as in the screenshots below:
opaque in Home screen
transparent in Recents screen
opaque in All Apps screen
Opaque white background in some launcher apps
These GMS apps are closed-source:
com.google.android.launcher Google Now Launcher
com.google.android.apps.nexuslauncher Pixel Launcher
In contrast, AOSP apps are open-source. Most launcher apps in Android are based on the source code of the following launcher apps:
com.android.launcher
Launcher (discontinued)
Launcher2 (legacy)
com.android.launcher2
Launcher2 (original package name)
com.android.launcher3
Launcher3 (for Android 5.0 Lollipop or higher)
Launcher3 source code
In the git branch oreo-release of Launcher3, LauncherIcons.java has the method wrapToAdaptiveIconDrawable that wraps legacy launcher icon in adaptive launcher icon.
/**
* If the platform is running O but the app is not providing AdaptiveIconDrawable, then
* shrink the legacy icon and set it as foreground. Use color drawable as background to
* create AdaptiveIconDrawable.
*/
static Drawable wrapToAdaptiveIconDrawable(Context context, Drawable drawable, float scale) {
if (!(FeatureFlags.LEGACY_ICON_TREATMENT && Utilities.isAtLeastO())) {
return drawable;
}
try {
if (!(drawable instanceof AdaptiveIconDrawable)) {
AdaptiveIconDrawable iconWrapper = (AdaptiveIconDrawable)
context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper).mutate();
FixedScaleDrawable fsd = ((FixedScaleDrawable) iconWrapper.getForeground());
fsd.setDrawable(drawable);
fsd.setScale(scale);
return (Drawable) iconWrapper;
}
} catch (Exception e) {
return drawable;
}
return drawable;
}
The flag FeatureFlags.LEGACY_ICON_TREATMENT is defined in FeatureFlags.java:
// When enabled, icons not supporting {#link AdaptiveIconDrawable} will be wrapped in this class.
public static final boolean LEGACY_ICON_TREATMENT = true;
So, the background color of legacy launcher icon depends on this flag, and it can be opaque in some launcher apps such as Pixel Launcher.
The background color
If the flag is set to true, a new adaptive launcher icon is created with R.drawable.adaptive_icon_drawable_wrapper, and the existing legacy icon becomes its foreground layer. The background layer is a drawable: #color/legacy_icon_background, according to the resource XML file:
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#color/legacy_icon_background"/>
<foreground>
<com.android.launcher3.graphics.FixedScaleDrawable />
</foreground>
</adaptive-icon>
The color legacy_icon_background is defined in colors.xml
<color name="legacy_icon_background">#FFFFFF</color>
So, the background color becomes white.
In Android 5.0 an icon always got an opaque background until I created a transparent file.
File > New > Image Asset.
Turn to Launcher Icons (Adaptive and Legacy) in Icon Type.
Choose Image in Asset Type and select your picture inside Path field (Foreground Layer tab).
Create or download below a PNG file with transparent background of 512x512 px size (this is a size of ic_launcher-web.png).
In Background Layer tab select Image in Asset Type and load the transparent background from step 4.
In Legacy tab select Yes for all Generate, None for Shape.
In Foreground Layer and Background Layer tabs you can change trim size.
Though you will see a black background behind the image in Preview window, after pressing Next, Finish and compiling an application you will see a transparent background in Android 5, Android 8.
Here is the transparent image:
Try this way that worked for me:
First, create a launcher icon (Adaptive and Legacy) from Image Asset:
Select an image for background layer and resize it to 0% or 1% and
In legacy tab set shape to none.
Delete folder res/mipmap/ic_laucher_round in the project window and Open AndroidManifest.xml and remove attribute android:roundIcon="#mipmap/ic_launcher_round" from the application element.
Delete ic_launcher.xml from mipmap-anydpi-v26.
Note: Some devices like Nexus 5X (Android 8.1) adding a white background automatically and can't do anything.
If i didn't get you wrong you have a png file with 512x512 px from a Photoshop file and you want to make logo from it for all necessary folders (mipmap-xxxhdpi to mipmap-mdpi).
You can also use this after creating icon using Android Studio too. I prefer creating my icons using Photoshop.
I use this site after creating a 512x512px icon using Photoshop. You can have icons not only for Android also for iPhone apps and and more and it's free. Icons are scaled correctly, named, and placed inside mipmap folders under android folder of the zip file. You just unzip the file after downloading and copy and paste.I made 50 icons at least and never had a problem.
I wanted to ask how to change the app icon of my app on a Galaxy S7 running on Android Nougat (see attached screenshot) to fill the whole icon space.
Is there a way to do this?
EDIT: I think it's because these apps have square icons and mine is circular. Is there a way to make it square for Galaxy S7 Nougat devices and for all others round?
You can disable this by adding a meta-data element to your manifest:
<application>
<meta-data android:name="com.samsung.android.icon_container.has_icon_container" android:value="true"/>
</application>
This solution is only for user's end:
Go to settings -> display -> icon frames -> icon only.
This should change the icons into full size icons.
From https://developer.android.com/about/versions/nougat/android-7.1.html
Apps can now define circular launcher icons, which are used on devices that support them. When a launcher requests an app icon, the framework returns either android:icon or android:roundIcon, depending on the device build configuration. Because of this, apps should make sure to define both android:icon and android:roundIcon resources when responding to launcher intents. You can use Image Asset Studio to design round icons.
While that may not be sufficient to deal with Samsung's "special" white frame for icons, this gif shows a few ideas for creating icons that look good whether they are the normal size or framed "Squircle" style.
https://www.androidcentral.com/sites/androidcentral.com/files/article_images/2016/12/squircles.gif
In any event this means you now have to worry about a normal icon, a round icon and a Samsung-ized icon and there is no way to provide an icon for the Samsung-specific launcher design.
I met the same problem and tried various things. Now I found one interesting thing.
If you make an icon without any transparency, the icon will be the full size on the Nougat android phone. When I made an icon in the paint.exe and saved it as .png, there was no problem.
I think this will help you.
EDIT : below is what I met, explained in my comment
EDIT2 : the sizes and shapes of two icons (with and without transparency) are identical. the only difference is one has transparency and the other has white background. Definitely I don't mean that I deleted transparency and enlarged the image.
EDIT3 : more explanation about my icons #Hadas