In my app I put an image as actionbar
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.header_edea));
The code is right, but I need the sizes for the different densities (ldpi, hdpi, etc).
Check the following link:
Design layout to support multiple screen
on Android Studio, you can choose an image for different layout sizes.for example, you add that image on Project -> new -> ImageAsset and it will show you or it will create that image for different sizes with different directories.(you can see the results in different drawable folders or mipmap folder with different sizes).
And after that, you just have to choose it and it will fix that for different sizes.
Android Studio has already a tool called Asset Studio described in LinX64.
For this purpose you can also check an online tool created by Roman Nurik called Android Asset Studio, which helps you to generate all needed image sizes: https://romannurik.github.io/AndroidAssetStudio/
Check this links - the first is a guide about creating icons, the second one give you information about all needed icon sizes for Android purposes like notifications or action bar:
Google's Design -
Icons
Icon Reference
Chart
Also on StackOverlow:
Action Bar icon size
Actionbar Logo size?
Hope it help
Related
I tried to change the ic_launcher.png icon from Android Studio's Config Image Asset. You can see its screenshot below:
But, When I deploy the app on the device, the ic_launcher icon seems the smaller than other icons.
I used photoshop and designed launcher icon. I, also, used Launcher Icon Generator to make the ic_launcher. The result is same.
The dimensions I used in photoshop to design the image for ic_launcher was :616x208 png.
You can use Android Asset Studio's Launcher Icon Generator. A web implementation is here. Your design will be automatically resized to support various screen sizes. Just upload your design, grab the .zip and extract it to res directory.
Make the Padding = 0% and Shape = None on that page.
When you code on Android Studio there is a standard icon symbol ( green Android ). I know how to change it. When I go to manifests.xml and look at this line
android:icon="#mipmap/ic_launcher"
the icon launcher must be in the directory "mipmap". When I go to mipmap, there are several .png files of ic_launcher.
Such as
ic_launcher.png(hdpi)
ic_launcher.png(mdpi)
ic_launcher.png(xhdpi)
ic_launcher.png(xxhdpi)
ic_launcher.png(xxxhdpi)
The question now is which of these files do I have to replace in order to get a new custom icon? Thank you.
You should use the Image Asset wizard. This allows you to add an Image Launcher which is the kind of image for your App's logo
Image Asset Pop-up Menu
Image Asset will ensure all resolutions and sizes for the logo.
They are categorized according to the size of screen for example tablet users uses xxhdi ic_launcher.png and hdpi ic_launcher.png for small size screen like 3 inches screen. If you are developing cool apps then you need to resize your icons for all these mentions size otherwise you can make any size and call them in manifest.
All of them because each one of them means that the icon will be displayed on the device depending on the size of the screen that is "from the smallest to the largest".
A tip if you are going to use the same icon for each one, first create the bigger image and then reduce it, I think the same android studio is reduced when you use the option because of the icon I think you can call application icon.
The biggest image is 512, this is the image of the web that will be displayed in the Play Store
I have an app that has buttons with background images that I specify in the layout. For mdpi and up it works fine and you can see the images. But I recently started tested on a small device and saw the backgrounds only show black. I then checked the screen size (small) which I cater for and also checked the density, which I saw in this case is ldpi. So I rescaled the mdpi images to 36x36 and created a mipmap-ldpi folder. Android studio sees it in design time but for some reason it is not picked up at runtime. So I Googled around and saw that I might have to add them manually via Android Studio. So I created a New Resource Directory where I specified the density as ldpi as below :
I then for each Icon added a new file with the same name and selected the ldpi folder as below :
And select ldpi directory :
I then entered the same name as it is with all the other densities for each icon / image.
After all this I still get black background so I thought let me try and assign the background programmatically. That then works. Can anyone help me with why it will not work when specifying it in the layout file. I have a layout file specifically for small screens. Must I specify density as well ?
Apologies for the images. I see I cannot embed yet because my reputation is too low.
Update 1 :
Moved all the icons to Drawables as recommended and it was still doing it.
Read other articles where LDPI is not really supported anymore and then answered the question as to make the problem go away by not supporting devices with LDPI density.
But the next day then picked the same problem up on a old S2 with HPDI density. So it is possibly not a LDPI problem anymore until proven otherwise. Hopefully we will find the problem and get it fixed.
The mipmap directories are used to store the launcher icons. They are not used inside the app, but at the home screen and the app listing.
The reason is, when a resource from drawable-directory is requested, a bitmap is chosen from the folder that matches the current density. But, when you use the mipmap drawable, the launcher may choose an icon from a different folder (usually a size-up). That's why you're not seeing the ldpi icon.
Some launchers actually display the icons larger than they were intended. Therefore, using the mipmap for launchers helps in this.
Also check this link out.
SUMMARY: use drawables for icons used inside the app and mipmap for the launcher icon of the app.
Apologies. I asked my question incorrectly. I assumed it was the icons but I neglected to mention I call the icons from Layer-List drawables. Turns out Layer-List draws black on some devices that runs Android 4.0 and 4.1 if you do not explicitly mention transparent as a color. I can now see all icons from ldpi up.
Thanks for your assistance. Reference link : Android xml layer-list not displayed correctly on some devices
I want to design layouts which will support multiple screen and resulution,the normal hdpi layout is okay but the other layout like large mdpi is not displaying as expected.Here are the samples
Normal Hdpi
Large Mdpi
There are two ways for it:-
1)use DisplayMetrics
2) Making different layout files
if you going for using 2nd way then refer this link
read this:
http://developer.android.com/guide/practices/screens_support.html
put your drawables accordingly in ldpi, hdpi, mdpi, xhdpi folders.
read this as well for design guidelines:
http://developer.android.com/design/index.html
From your comment it seems like you want a background image for different densities.
You can achieve that from eclipse like this
Press ctrl+N(File-->New-->Others) ---> android---> android icon set-->Choose your preferecnce, provide the name & press next--->under foreground tab, press image---> provide url of an image----> press finish.
This will automatically create an image of different densities in your different folders.
Or if you dont want to use eclipse then,
http://romannurik.github.io/AndroidAssetStudio/
this link will serve the same purpose.
Is there a way to get Eclipse to automatically re-size images and put them in the appropriate drawable folders? When you add an image for the icon when you first create an Android project, it automatically re-sizes the icon and puts them in the appropriate folders. I know you're meant to scale images using a 3:4:6:8 scaling ratio (http://developer.android.com/guide/practices/screens_support.html). I'm wondering if there is a way that Eclipse does this automatically for images?
For re-size icons, right click select New/Other… or press Ctrl+N, select Android Icon Set, the default name for icons is ic_launcher, click Next, in Foreground select Image and Browser that image like to put as icon and is re-sized automatically
Is there a way to get Eclipse to automatically re-size images and put
them in the appropriate drawable folders?
NO, until now, you have to create your own resources defined for every "Screen Density", tools like android_img_resizer will work but can´t support all densities, what if you need resources with mhdpi or tvdpi density.
More info:
Supporting Multiple Screens - Using configuration qualifiers
Designing alternative layouts and drawables
Supporting Different Densities
For re-sizing the images in bulk i will recommend you this tool https://github.com/bearstouch/android_img_resizer . its easy to install and it support the new resolutions (xxxhdpi,xxhdpi) as the base image.Check it out.