Android development - Drawable images resolution, how to export? - android

So, I am just a beginner and I already went trough android documentations about supporting different screen sizes and I understand most of it.
For my app, I created different layouts for each screen sizes and on the emulator it looks good.
Just one question.
How should I export images to my drawable hdpi.lpdi,...mdpi...folders?
Because, What I did was, I used art text2, and created a project with 700x700. Well. I set it to transperant, so it's not excatly 700x700px. cause the image does not fill the entire space.
So, before I hit export, should I change the PX Resolution for example for 450x450 or something for mdpi? But, I didn't do that, and I amnot sure if I should have done that. then i hit export and it asks me where i want it to save the image. It also gives the me option to the change the DPI Resolution in DPI, i changed to 160 and saved that in my drawable/mdpi folder. But I did not change PIXEL resoultion.
So, was it correnct? or should I have changed the pixel resoultion before, I export the actual image?
In Eclipse, However, I change the width and height of the image in dp not px. so it doesn't take the entire screen space.
I checked my app on different screen sizes in Eclipse and it looks awesome. But, in the emulator, it looks cool. HOWEVER, if open my hdpi emulator the image does not look very sharp or clear. What's the problem?
The image itself looks clear and sharp if open it with my image viewer on my computer even, the image viewer window is almost taking the entire screen of my laptop (14,1280*800).

I will suggeset you to use 9patch image. you can create 9patch image using android tool called draw9patch Located in sdk/tools.What you have to, create a high resolution image and then give to draw9patch tool it create image with extension .9.png and use that image
See the link for detail
http://developer.android.com/tools/help/draw9patch.html

Okay if i understood right, then you need to have 4 res for each image, and the aspect ratio will be "1:1.5:2:3" and some times "1:1.5:2:3:4" so you have to get all the images that you need in 3 or 4 sizes and let the android os properties do its magic by choosing the right picture based on the screen size.

Related

Large 10000x11866 .PNG image still blurry in Android Studio

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.

How do I set an image as background without blurring?

I am using Android Studio. I am trying to set a screenshot from my device, as a background image for my activity -
android:background="#drawable/active"
I have my image inside the directory- res> drawable-ldpi> active.jpeg , Which Is the lowest density folder available I am aware of. The problem is, The background looks PERFECTLY crisp and sharp in the screenshot, but when I set it as my activity's background, it blurs.
How do I fix this? I have tried moving the image to the highest density folder drawable-XXXhdpi, but it becomes worse. I have even tried the drawable folder.
All depends on your phone density. You should make few version of your image for each pixel density (but remember that even mdpi is growing older). If you properly resize image for each density your phone should take needed size of background.

Android: Bitmaps resizing themselves on higher resolution devices

I'm making a game on Android in Eclipse, and when I run it through the emulator, it appears fine. The emulator I set up has the resolution at 800x480 (sideways). When I run the game on my phone, with resolution 1920x1200, it screws up the bitmaps by only drawing a fourth of them. I've made test code and two screenshots to show what I mean.
Small screen, emulator, running 2.3.3
http://i.stack.imgur.com/2WstK.png
Large screen, Galaxy S4, running 4.2.2
http://i.stack.imgur.com/8wtAD.png
It's the same code on each. The top has the dimensions correctly in the emulator (frame size of the bear, which is 64x64), but on the larger resolution it's halved the width and doubled the height for some reason.
The bear at the bottom is set to be near the bottom coordinates whatever the screen size, which is why it's different in each screenshot. The rectangles and top bear is set from the top coordinates.
I can post code but I'm just wondering if it's some type of setting that I'm unaware of because of the difference in resolution.
One more thing, I have the rectangles flipped horizontally from their original bitmap, so the fact that it appears to have taken the top right part of the bitmap to draw is not part of this, as far as I know. Again, just wondering if it's some setting that auto-scales things if the resolution is huge. I have a feeling it's something like that, OR that it's running on such a newer version of Android. Could be lots of things I guess.
Android usually scales up / scales down the image if it cannot find the right image assets for the device resolution. I believe this could be the reason for the behaviour you are observing. You can read more about providing the proper assets for different device configurations here,
http://developer.android.com/guide/practices/screens_support.html
Alternatively, if you don't want android to scale your images you can also place the image resources under drawable-nodpi folder.

Android layout multiple screen

Sorry but i cant understand how i can draw a right picture for the right android phone size.
I readed the android documentation, and they say for i just think in screen size and density and not in resolution, so what size should have my picture?
For example,if i have a phone with size 1000x400(stupid example),and want a button(40x40) that will be in middle,what size should i do?? 40x40?? But in documention they say for dont look for resolution :\
Im confuse...
ps: The documention link Android multiple screens
Basically you'll have to realize that although resolution, screen size and screen density are separate attributes, they are still somewhat related. If your button is 40x40 as you mentioned, and that's the size you find looks good in the center on a hdpi(high density) device, you will have to scale it so that it fits accordingly on mdpi(medium density) and xhdpi(extra high density) devices. What I like to do is use PhotoShop or another graphical editor and resize my assets so that they fit on whatever density devices I'm trying to target. I make sure to always use *WRAP_CONTENT* for my height and width attributes and never fixed values.
Also, if you do not include these scaled alternatives in your res/drawable folders..you're basically saying that you're relying on the system to scale them for you, which can be a gamble. So I always go with resizing my assets so that I include a version for all densities. The link you posed explains everything pretty well

Android screen resoulution problem

I'm writing a game for Android and can now test it on a second device, the Nexus 1. The game uses fix pixel-values, just using bigger cutouts of the background for high-res devices. So I thought there would be no problems. Somehow, however, the nexus 1 is making a specific image bigger than it should be (261*66 instead of 174*44). The picture itself as a resource is 174*44, so it's being stretched. Why? What can I do against it?
Edit:
Spritesheet = BitmapFactory.decodeResource(res,
R.drawable.bird_spritesheet);
Is the used code.
Edit 2:
Is there no way to tell the software to just use the size the picture is? I don't want to bloat my software by adding multiple pictures (/drawable-hdpi/ answer).
The pictures are supposed to be smaller on bigger screens.
what drawables folder to you have the picture in? If you put a copy of it in drawables-hdpi I think it will show up real size. It is really better to set things up in such as way that the final size in pixels it ends up is unimportant. Using pixels values is going to ensure that your app looks wrong on at least some of the screen sizes out there.
Because Android runs on multiple screen sizes and you use device independent pixels (DIPs), images get scaled to ensure they look the same on all devices. To avoid this, you can provide alternative resources for high density screens (in your case) and for low density screens.
More info about screens here

Categories

Resources