I have a set of 4 images I plan to display at the first launch of my app inside of a ViewPager. Each of them is 1MB, so that's 4MB total
I want these images to be shown for any density screen.
Where should I place these images?
In which size?
Will duplication increase the size of my app?
Maybe a more efficient way to do it? (one location for these drawables)
The closest I've found is http://romannurik.github.io/AndroidAssetStudio/ but it's only for icons
Thanks!
Q1.2. Location: /res/drawable. You can have many version of those images and place them in different folder: drawable-hdpi, drawable-ldpi... For better result, please read http://developer.android.com/guide/practices/screens_support.html
Q3. Duplication will definitely increase the size of your app. But common users will possibly ignore its size is not ridiculously big.
Q4. You can store only one image for every screen size, but you need more coding work to scale the drawable to fit the screen of different device. For better result please read: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
Related
If I put my application resources in drawable-xdpi then it is automatically down converted for hdpi, mdpi and ldpi by ration 0.75, 0.05 and so on.
Why we need to create extra resource if one type is enough only?
I believe it is enough if I create for xhdpi and let Android down scales automatically. I have gone through this question
What is the best way to create drawables for different dpi
but no one has given answer that yes you can go this way.
Suppose I kept my images in xhdpi and when app opens in hdpi it will reduce size to 0.75, when it opens in mdpi it reduces size to 0.5.
So what is best way to create draw able asset? Please suggest perfect way with valid reason.
If not needed why we are creating so many resources instead for one only like xdpi?
There are two reasons to provide more than one image:
it is more efficient to load an image that is already the correct size.
The automatic downscaling may produce artifacts, which can be disturbing especially for small images. So if you want a pixel perfect image it is better to provide one in the correct size.
If none of them is a problem for you, it is also fine to go just with one image.
If u want to display same image with different resolutions in devices
xhdpi image then place it drawable-xhdpi
hdpi image then place it in drawable-hdpi**
or to maintain a drawable folder place all the images what you want to display it will display with same size in all devices irrespective of the resolution.
What is the size of the background images (png files)? How do I determine the size of the image? (I would like to cover the entire relative layout, thus the entire screen)
Do I need to have several png files, all with the same image but with different sizes to be supported on all screens? (3.7 inch, 4.2 inch, tablet size and etc...)
Can anyone help?
I though of having 1 image and then streching it according to the screen size retrievd from the device system, is this the correct method?
you can use fill parent but for accurate info
use http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch
it will help you to provide resources it is the developers site -- it has info on providing resourses you can also see supporting multiple screens for better understanding
Simple question actually and I have spent hours searching for an answer.
What is the best way to provide bitmap resources that fill the full screen? For instance for a full app background or something.
Currently I place all my images in drawable-nodpi in a medium resolution and obviously need a lot of custom scaling. I do need images the fill the full, or the half or a third of the screen width. What is the best way?
Michael Ellen states ( https://stackoverflow.com/a/6938345/1162415 ) that e.g. drawable-ldpi has 240 px screen width. While I would love this to be true I do not think so. Table 3 at http://developer.android.com/guide/practices/screens_support.html#testing clearly says that ldpi might result in actual px resoluation width of 240, 480 or 600.
Should I build the app with drawable-*dpi fixed for screen sizes, something like drawable-ldpi-small and so on? We do make use of 78 cards ( https://play.google.com/store/apps/details?id=com.pinkwerther.tarot if you are interested) which should be displayed almost full screen. That makes a hell of an overall app size. Either that or a hell of a lot of different apk files.
Now there is one solution I am currently thinking of that might be suitable. Namely to provide kind of low resolution default images and have the apk with an expansion file ( http://developer.android.com/guide/google/play/expansion-files.html ) of really high resolution images which get scaled and stored on first use. Before I dive into this possibility I just want to make sure there is no simpler solution... So please feel free to hint me to the hidden places I happen not to be aware of!
Is there a way to have Android select a different image based upon the screen size? According to the docs and my testing, images must be placed in folders like drawable, drawable-mdpi, drawable-hdpi, etc.
These folders however relate to the screen dpi and not the screen size. The layout folders are used to handle different screen sizes but they don't allow you to store images in them. Only xml files.
So if I run my app on two devices with the same dpi but with different screen sizes, the same image gets selected from the same drawable folder. What I really want is for a larger image to be selected for the larger screen and a smaller image for a smaller screen.
Thanks for your help.
Yea, you are right, this is how works Android, by saving different pictures in particular folders (l,m,h and xh -dpi).
Where is your problem?
You want to keep images for all screen resolutions? Its too many of them.
Can you write more specific what you want achieve?
If you have a problem in layouts.xml, just check:
android:scaleType="..."
You can use 9-patch images. A 9-patch image can be stretched without loosing quality. You may refer to the following link for more information http://developer.android.com/guide/developing/tools/draw9patch.html
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