So whenever I import an image as an image asset it is always blurry. When asked what type of asset is it I always select launcher. (Because thats the only way.)
I'm using the drawable as part of a selector, one image when pressed and another when not. Is there another way I can put an image in android studio?
Use Draw 9-patch tool to create bitmap images that automatically resize to accommodate the contents of the view and the size of the screen.
You can get this tool from your Android SDK sdk/tools directory
http://developer.android.com/tools/help/draw9patch.html
Note : I You want to put image according to device resolution add your image to these folders hdpi, xhdpi ,xxhdpi
You can put images in Mipmap of all the resolution in different folder like hdpi, xhdpi ,xxhdpi and you can use it
Related
I want to have an image show up in my Android application, but it always comes out blurry. What do I do? My image is 10000x11866 pixels, and I've made it big on purpose so that it wouldn't come out blurry, but it still does.
Here's my approach: right click the 'res' folder -> new image asset -> set icon type to 'action bar and tab icons'
What am I doing wrong?
Action bar and tab icons are much smaller than that, so the wizard is scaling down the image. Do not use the Image Asset Wizard for your image.
Instead, create a drawable-nodpi directory under your existing res directory in your module's main source set. Then, copy the image into that drawable-nodpi directory.
Note that you may run out of memory with an image that size, and there is no Android device with a screen resolution anywhere near that. I recommend that you reduce the resolution to something more reasonable, such as 1000x1186.
You can just copy the image and paste it in the drawable folder. Make sure the name of the image is in lowercase.
Also, make the dimensions smaller. There is no need for the picture to have such extreme dimensions. Especially if the image is not being zoomed. 1920 x 1080 1000 x 1000 are big enough trust me.
Post your code so we can see what's going on.
I am directly adding images in drawable folders and it is coming fine with ImageView tag android:src="#drawable/image_name" but I wonder what to do with the other drawable folders as shown below.
Do I need to add same image in all drawable folders or my way of adding images in drawable folders is wrong?
Please help me!
The image is same, but the size should be different for each folders.
If you add the image only in drawable folder, same image will be loaded for all screen resolutions. So for eg: if the image size is small, this may result in bad image quality.
You can find a similar question here
I use Android studio plugin Android Drawable Importer
All these drawable folders represent different android phone densities. The best folder to put your images is drawable-xxhdpi as android automatically downscale or upscale the images depending on your devices density and most phones these days are on xxhdpi density.
If you put a image in drawable folder only there are chances that image may get distorted(as it upscales) in xxxhdpi density.
If you are putting images in xxhdpi ,make sure you create your images acc. to xxhdpi resolution.
If you don't feel the image is looking right in some phones than check the density of that phone and put an image in that specific density folder acc. to it's size(reduced or increased).
Just put it in the drawable folder, no need to put it in other drawable-... folders because those folders and contents inside are created automatically by android studio.
I have an image with resolution 300x450. I want to use it on an Android Studio app.
When I create a new "Image Asset", the pic looses its resolution, and if I select manually the resolution at the ImageView, it pixels.
What can I try?
Thank you
Fixed. The problem is, that you mustn´t to insert it as "Image Asset", you just have to drag the pic, to the Drawable/xhdpi folder. Then, you can to use it, with no problems.
The image size you are using should have the resolution for the highest density (xxxhdpi) beacause when you create a new Image Asset, Android Studio create N different drawables for that image, one for each density, using the one you have as the "xxxhdpi one".
For example, let's say that image 300x450 is for a xhdpi screen. When you use that tool to create Image Asset, Android Studio will create a xxxhdpi asset 300x450, a xxhdpi 225x337, a xhdpi 150x225, and so on... And you try to use that xhdpi 150x225, in the same place you should use 300x450, and it pixels.
So, my solution, if you don't have the highest to generate the other ones, you should put that one directly in "xhdpi" (or the one it is designed for), and you can be sure that at least all density or lower than that, will be OK.
Just use scalable option in properties menu. in that select fitXY option and adjust your coordinates with height and width properties
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
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.