I am trying to understand screen sizes and densities and what I really need to do in order to make my multiple choice question game work on every Android screen nicely. I want my game to look the same in every screen size and density meaning no changes to the layout and good looking images.
Basically my game displays questions which are png files, and answers to choose from which are also png files. I specify each imageview size and imagebutton in dp, and the locations of these on the screen in dp. For my layout background image I just have it fill parent width and height.
So my question is why can't I just have one drawable folder with hdpi images? Therefore, the images would be scaled appropriately in dp on all screen sizes and located in the same place and look the same on every screen. And the images would look good on hdpi screens and smaller ones? Also, why can't I just have one layout folder with the same explanation?for your answers!
You can create the only one folder but the images in that must be .9.png bcoz these images stretched according to the screen. Another way is create the different size images and place them in the hdpi,mdpi,ldpi folders.
You can create only one folder for both ressources. But for image, if you dont want to get uggly stretched image you should create 3 image size with different dpi for each folder. Your picture will be sharper for hight dpi screen and faster for low dpi screen with a picture near the final size.
Related
how to use vector images which scale up and down according to the screen sizes?
I m using a vector image in my project but it is not scaling in big screens.
what you mean by being scaled ? maybe you are misunderstanding.
if you mean the image size would be changed in various screen sizes such thing wont happen. the image size is what you provide in your imageview (or any otherview using the image).
the only different between vector assets and normal asset is that vector asset are redrawn every time so you wont have a low quality image no matter how big it is and which device it is being shown in. so you wont need to save various size of image for various size of screens.
if you want to change the size of image just change the imageView height and width. you can use dp (density independant) unit.
you dont have to do anything for support vector images for diffrent screens its already scale for the relevant dp, Can you give more details about your problem when you say "it is not scaling in big screens?"
maybe you want the image on tablets will be bigger?
I am creating an app for different devices and I added images with different sizes in drawable-small, drawable-medium... to add the same image for different devices but I need to increase the size of the image when the size of the screen increases is this the correct way?
plus I need to increase the font size when the screen size increases how can I do that and if I used the layout-small... folders what font size will be the perfect size for the devices with small screen size (portrait and landscape) and for the medium and large..?where can I find this info as I am trying and trying different font sizes but there must be another way!!
thanks.
This is a very rookie question but here goes:
You set the text and image sized in dp (density pixels) so screen size and resolution is irrelevant.
As for making multiple drawables for each screen size is a good idea but not a necessity since you can choose how much of the screen each picture will take, but on bigger screens make sure the resolution of your images are high enough to look good.
For scaling a particular image to all screen size you can use nine patch image. There will be drawninepatch.bat file in the tools folder of your sdk. Open that , drag and drop the image , and you want to expand the image based on your needs. Now after the nine patch is created put that in the drawable folder. This image will expand accordingto the screen resolution and densities.
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 am looking at my android design for medium and large screen. I have designed my layout for mdeium screen (viewing it on the eclipse editor and emulator) and making sure it is good. My design involves textview and images view. I have create the 3 drawable folders for different density sizes so the picture can occupies the rough space on different densities.
Now, I am looking at the large screens (and even xtra large screens) but my textviews and images views looks very small (compared to the size of the screen). Therefore I would like to make use ofd the extra space by enlarging everything.
I know how to do it for text views, basically I would make textsize bigger (ie. instead of 12 sp I can make it 16sp)
But How can I do it for ImageView? The Imageview displays the image according to its size. And the size of the image is really meant for medium screen. How can I make it bigger? Should I provide the same image with a bigger size and a different name?
Please help, btw plz dont point me to the android develoment supporting mutliple screens cause I read it and I couldn't find what I need unless I missed a certain line that answers my question.
Thank you for your help
Decided to edit the question maybe people can understand my question more.
I have an image that is 50 X 50 pix in medium density medium screen size. Let say that this image occupies 5 by 5 millimeters, Now if I want to display the same image on medium desnity XLARGE screen but I want it to be bigger (say occupies 10 by 10 millimters). How do I achieve that? I understand I wil lneed different layout in the XLARGE folder so in this layout what should I do with that image view? Do I create a new PNG file with 100X100 pix and place it in the medium density folder?
you can use layout-xhdpi ,layout-hdpi etc..as per your requirement.
All of your screen xml files can be placed in multiple folders (layout, layout-large, layout-xlarge, etc.) in which you can scale the size of the UI components in DPI based upon the size of the screen. See Android documentation here.
i am putting the image in three of the drawable,drawable-hdpi and drawable-ldpi for supporting all type of screen but when i see the output of background image in 240*320 screen resolution the background image is not as clear as origional so my question is where to, means in which folder i put the background image for supporting it all type of screen size and density, maens then my image should not distorted or bluer...
i am using the background image of size:320*480
thanks
make one folder name
drawable-nodpi
put your image in that and use it and dont keep that image in other folders.
the image will not be scaled or stretched.
Anoher Way
the best way is to make 3 different size images and put int drawable-ldpi(240X320),drawable-mdpi(320X480),drawable-hdpi(480X800) folder with the same name.
TO LEARN MORE PLEASE VISIT THIS LINK.
Supporting Multiple SCreens
You can put different same image in drawable-hdpi,mdpi and ldpi.Depending on the density of devices they will take the images from the corresponding folder.
With different devices you should have same image but with different size and density.for You can search in internet the specifications of devices.If density is less than 160 then put image in ldpi,if 160 then use mdpi and if 240 or above use hdpi.Also change the size of image to the screen size of corresponding device.Hope it will help.