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.
Related
I want to use the default launcher icon provided in android studio as an ImageView. I used the android:src="#drawable/ic_launcher_background" XML tag in my imageView
But I got this as the result:
But I want this in my ImageView:
you are setting ic_launcher_background for this ImageView and you got it
till Android 7 app icon was a single image, oftenly called ic_launcher. Oreo introduced Adaptive Icons, which have two layers - background and icon/logo itself. so you need two ImageViews or LayerDrawable, the second/top layer will be your icon/logo (ic_launcher_foreground? inspect your drawable or mipmap folders)
note that background layer may get some cuts in device launcher - may be square, but also round, rounded corners all or only one etc. also foreground/icon itself may move a bit, just like visualised under above link - when you use old icon ic_launcher on newer devices it won't be exacly same as shown in device launcher
Try this
android:src="#mipmap/ic_launcher"
Hope this helps...Feel free to ask for clarifications...
The default icon provided by the android studio is actually a combination of two different drawable. See the below picture (you can check the same in your project). You can use the icon as an ImageView by stacking one of the drawable on top of another (which is not a good idea) or you can also directly use android:src="#mipmap/ic_launcher". Just as #Vishnu said.
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"
I'm having trouble configuring my launcher icon using Launcher Icons (Adaptive and Legacy). I created an already round PNG icon as an example.
I want it to appear just like that but the background layer cannot be set to transparent.
Is it possible remove the background layer? What is the recommended way?
I have following issue, am developing an App for Android and I realise that the launch icon AKA ic_launcher is quite smaller than al the rest of the App that I got from GooglePlay.!see image below.. I tried as normal (on eclipse: new->android icon-set->....) using a 512x512 png file, then I gave a 2nd try using a recommended link I found by searching a solution (Android Asset Studio)
you may want to say " is not tooo much" but that is what I need, must be the same size as normal apps...
thanks in advance!
see the dotted line as reference to verify the size
Just create icon 512x512px without any generators, they add margins to a picture. You have to draw icon from border to border.
Use an existing application icon as a template, for example - mine
I have realized that there are at least two background colors on Option menu of Android. On the HTC Hero, the background is white and on Samsung Galaxy S II, the background is black.
This became a problem when I set the icons for the background menus. Is there some way to detect the background color of the Option menus in Android?
Possible solutions:
Don't use icons.
Design icons according to the guidelines - http://developer.android.com/guide/practices/ui_guidelines/icon_design_menu.html. There are three different guidelines for up to 2.2 (white background), 2.3 (black background) and 3.0+, so it's a lot of work...
As Profete162 suggested, use #android:drawable/ic_menu_*
For Android 4.0+, you can also set the light / dark Holo theme, which is guaranteed (at least in theory) to remain unchanged across different phone manufacturers - so it'll look the same in HTC Sense, Samsung TouchWiz etc.
That's indeed a very annoying issue.
On my implementation, I always try to use standards icons from android.R.drawable.IC_menu_*, so I am sure these icons are part of the framework and users are always positively surprised to see their generic icons in my app!
That gives a really good continuity in the user experience on the device, but that doesn't answer your question, but at least provide a workaround.
Here are for instance all android 2.2 icons: http://androiddrawableexplorer.appspot.com/
You can trust me, using these icons will always fit your colors.
First of all to answer your title question:
You can reference and read the background of the options menu by reading the attributes of the current theme. The attribute for this is panelFullBackground. E.g. set it as the background of a textview in XML¹:
<TextView android:background="?android:attr/panelFullBackground"
... />
Note that the background seems to be a solid color, but it's not - it's actually a bitmap. If you look closely you can see a grey border at the top (android 2.3+), or a drop shadow (<= android 2.2), so its'a bit difficult. Luckily there is a different attribute called panelColorBackground which matches the background color of the drawable as close as possible. So if you want just the normal background color, use this instead.
¹ This can surely also be read from code, but I don't know how from the top of my head at the moment, maybe I'll look it up and edit it in later.
Regarding icons
So you have the color as stated above, but you still have to process it to know if it's a dark or a bright color. You can do that, but that's not the usual way to deal with these icons and probably a good bit of work until you cover all the possible cases - not to mention that you have to create icons for each variant.
Normally you should adopt the platform menu icon style. This works across all devices and looks familiar to your users (custom icons that dont follow this often look "wrong" - e.g. astro file manager does this I believe).
You can do that by hand (see the guidelines), but the way better alternative is the Android Asset Studio.
It comes in two flavors:
As a webapp
Integrated in the latest version of the ADT plugin for eclipse
(under File->New->Other->Android Icon Set)
The workflow for both is pretty similar, select the point "Menu Icon" and follow the wizard. It will promt you to enter a simple, black and white bitmap of your desired icon that just outlines it's shape. After you specified one, the asset studio will generate everything for you. Play a bit around with the "clipart" option, that has a few example bitmaps ready to see how it works. When finished, the webapp gives you a simple zip which can be extracted into your project directory, the eclipse version adds it directly to the project that you select in the wizard.
The background color can be anything, because its implemented in Framework by manufacturer. You can't read it, in fact you will never need to read it.
Just create your custom menu layout in res/menu folder, set style and use it.