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.
Related
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
I have an application where I use background images.
I don´t want my images to be stretched or deformed when I run my application on different screens with different ratios.
I already have different images for different screen sizes.
Can someone please explain to me how Android Studio handles the image sizes.
How can I make it that the image isn´t streched, but a sector that fits the screen is being displayed?
Android System uses resource qualifiers/filters to load different resources based on current screen configuration.
Now you have different images for different screen sizes, Good!!
the Folder structure would be something like this.
res
-drawable-mdpi
-drawable-hdpi
-drawable-xhdpi
-drawable-xxhdpi
Now when you run your Application on a device with mdpi screen, android loads images which are under drawable-mdpi folder, and when you run your application on a device with screen density of xhdpi android loads images from drawable-xhdpi folder.
Instead of setting the image as a background for my layout I created an image view. There I set the scale Type to centerCrop and it had the wanted effect!
To my understanding, I need to create several different versions of my image drawables, varying by size so that devices load the appropriate one.
In my Photoshop mockup of my app, I have an icon image that is 12px x 12px on my monitor.
What various sizes/dimensions do I have to make of the icon?
Should the icon stretch to the sides of the drawable's dimensions or should there be some padding?
Thanks.
Scroll down to 'Alternative drawables' to get your answers:
http://developer.android.com/guide/practices/screens_support.html
The size of your photoshop mock up will define what your base is.When I'm not sure what I do is take an icon and drop it in one of the drawable folders, for example let's say xhdpi, and only in that one. From there I launch the app and see how the icon look on my phone. If it's too small then I move to the next folder down, in this case hpdi. If it was too big I would move it to the next folder up, in this case xxhdpi.From there you can calculate the size of the other drawables, using the example on that link.
For reference see the sizes of default ic_launcher icons provided by android for your app in every drawable or mipmap folder when you first create a new project.
See the sizes in pixels and do the same for your custom icon.
Its your wish if you want to give padding to your icon image or not. Its up to you how you want to make your icon look.
I need to add an image as an Activity Background so.
I right clicked res folder > New > Image Asset
and I imported a picture under Launcher Icons category. But my pictures have been resized and the quality has been lost. Is there anyway of importing the original image and its quality without having to resize it through Android Studio?
Also, how would I reference it in my XML? I'm used to eclipse and what I usually do is:
android:src="#drawable/MyPicture"
ALSO, How would this affect screen sizes since I'm avoiding resizing? The original image size 900 x 678
You are importing them, as you said, under Launcher Icons category, which will automatically try to resize them to 48dp (and the respective px for the resolution density). You probably just want to navigate to your project and copy paste the image into the drawable folder and then refer to it as you mentioned in your question.
android:src="#drawable/MyPicture"
Your other option is to create different sized backgrounds and copy paste them into their respective drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi, and drawable-xxxhdpi folders.
Android will try to scale your image to fit the screen unless you specify a scaleType: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
I am new to Android and I need to use images in my XML file.
A tutorial says that I have to place them in drawable directory, but I can't find it as I find drawable-hdpi, etc.
drawable folder is divided into into three part according to device screen size h- high, M- Medium, L- Low because in android different size of device available in the market and android device screen divide into three type h,m,l based on density specific according to device size android pick the image from specific drawable folder h ,m ,l if you dont want to density specification in your application then add new folder with the name of drawable.
I hope it is more use full to you.
You can create the drawable folder yourself by right-clicking "res" -> "New" -> "Folder" and naming it drawable.If you do not need your images to be density-specific, you can put your images there.
you can create your own drawable folder in res directory. But remember keep the images in that folder which are common for all screen size devices. drwable-hdpi means this directory contained the images will be loaded when the device has higher dpi. similarly drawable-mdpi and drawable-ldpi are there.
Those which you found are drawable folders.. Insert the images in all three of them. So that at time of change in definition of screen images can be changed accordingly. For now, Insert same image in all three of them.
You can create your own drawable folder. But its good to use these at first then when you run your application on device you will come to know the difference.
drawable-hdpi drawable-mdpi etc are the different type of drawables . you can keep your images in these folder (any one at the initial level).
But they have some diffrence according to the resolution of the screen & density of android device. Further you can check the diffrence between them and keep the images as per need.
see this for more details: Explain the difference between drawable, drawable-ldpi, drawable-mdpi and drawable-hdpi
and Supporting Multiple Screens
you can create a drawable folder in the /res folder of your project and put your images there.
drawable-hdpi(mdpi/ldpi) are used separate different resources for different type of screen. take a look here to know more about multiple screen handling
I realize that this question is rather dated, but...it came up when I Googled the issue of inserting images into an Eclipse Android project, so....
Actually, those folders are mipmaps and they are used by the graphics subsystem to provide seamless zooming, as well. I would suggest creating proper mipmaps using an editor, as opposed to providing only one resolution choice.