My question is straight forward and simple, Like there is layout-sw600dp,values-sw600dp, for layout and values respectively, what is there for drawable folder in relative to size of screen.
I read in various document that if we want to use any screen more than or equal to 7 inches we can use layout-sw600dp folder, and for any lesser screen size device, layout folder will be taken into consideration. So how we can make use of same concept for images also. Right now there are ldpi, mdpi, hdpi folder, but images are taken in accordance of screen density not with screen size.Now if I am developing an app which work both on device and phone, what should be my probable approach for images.
Thanks in advance, please guide me.
you can also use the same concept for drawable like drawable-sw600dp,drawable-sw600dp-mdpi etc. I have used this in my application .
I'm not 100% on this one, but I think you can also use the same convention with drawables. Try drawable-sw600dp-hdpi or something similar. Though I also do have a few questions you may want to answer before proceeding:
Why would you want a different image (not resolution) for a bigger screen size?
As you already know, a 7-inch device would be using the layout-sw600dp folder, so why not have a different name for a different drawable? That would look a lot cleaner, imo.
Related
I have scrolled through loads of documents and questions trying to figure out the right way of giving proper UI experience. I have a app with complex designs . I need to know how to scale my design to look fine in all devices. I got solutions mentioning that a normal layout folder with all layout , and i have traced all textview sizes and image view sizes to values, values-sw 480dp, values-sw 720 dp . Is this the proper dimens? My problem is that though the textsizes and image sizes scale up , still UI doesnt seem right. I mean the margin and all. What is the right solution out? any help?
#D try out to make different folder for different screen sizes like layout-hdpi
you can find the best practice for layout handling hear
and see the Google documentation hear
Good luck..
Its better to use Drawable qualifiers also
drawable
drawable-sw320dp
drawable-sw480dp
drawable-sw600dp
drawable-sw720dp
I want to show some images on the background that is also image. Say my background image contains an empty squares, and I want to show an apple image that must appear exactly in one of that squares.
I have a problems with the apple sizes, as the background scales and fits the screen, but apple image stays the same for the different resolution and the same density devices.
Say I have two ldpi devices with 240x320 and 480x800 resolutions. When I keep my drawable aple file in the drawable-ldpi folder, and use wrap_content for height and width (or fixed dp values) those 2 devices draw the apple with the same size, like it is described in the documentation.
The LinearLayout works slow when I stack them.
Using RelaytiveLayout I must programmatically resize the images which is also "not so good" solution I guess.
I've found a solution here https://github.com/intuit/sdp that maps the dp-s.
They set dimen-s for values-sw300dp to be
<dimen name="_10sdp">10.00dp</dimen>
and for values-sw480dp to be
<dimen name="_10sdp">16.00dp</dimen>
and so on for the different cases ...
So when I set the with of the apple to be _10sdp it means different dp-s for my 2 devices with the same density and solves my problem. Is it a good solution as it seems to be for me?
Is there any other easy ways?
This is indeed the recommended solution as you could see in the iosched github repository which is a generally good source of knowing whether something is a desired common practice at least according to Google since i know they spend a lot of time to create this code to reflect the best practices and obtain the new APIs
Your solution seems good, just as common solution, would be good to use folders described in documentation.
For your case, as easier solution I would suggest to not use an apple image separately and place it in background's square. You can have an image: apple in square, and place it on background wherever you want. An apple will always be in a square and you can avoid tiresome process of creating dimens for each configuration.
Its very clear for me what sizes should I use for the different versions of ic_launcher.png inside drawable-hdpi, drawable-ldpi, drawable-mdpi, etc.
What I don't understand is what sizes should I use for a picture (a png) that is simply used in one Activity as an ImageView.
I have this image in high resolution
In a normal pocket device this image should be like 90% width
In a tablet or larger devices, maybe 90% is too big
So, the question is:
Should I create several versions of this an_image-file.png for each folder in drawable? or just use a single version of it and adjust its width via XML? I'm asking because I'm worried about using the best practice in this subject.
There is no clear answer. Only way you can solve this is by trial and error. Sizes are defined for icons only for other image views you will have to try it on 5" smartphone 7" nexus 2 tab and 10" tablet.
At least for these three resolution you will have to create images, for other devices XML layouts will automatically adjust.
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 newbie as far as android application development is considered.
I am little bit confused about drawable folders.
In the tutorials available on the android developer site they have mentioned about the drawable folder. But when I create android 2.3.3 application I see three folders drawable-hdpi, drawable-mdpi and drawable-ldpi.
I know that this for screen resolutions. If I have an image as a resource I have to create equivalent three images with different sizes and put these images into these three folders.
But for example, I am working on a localization (German) with images. Should I create folder drawable-hdpi-de-rDE similarly drawable-mdpi-de-rDE and drawable-ldpi-de-rDE or should drawable-de-rDE be sufficient?
If drawable-de-rDE is sufficient what will happen if it is run in mdpi or ldpi?
Please clear my doubts regarding this.
Thanks
Pankaj
Should i create folder
drawable-hdpi-de-rDE similarly
drawable-mdpi-de-rDE &
drawable-ldpi-de-rDE
If you want to make your pictures (at the right sizes) yourself, yes, you'll have to create directories that are specific to both the culture and pixel density. However, the culture should come before the dpi, or the project will not compile. For example, the following would compile correctly:
drawable-de-rDE-hdpi
drawable-de-rDE-mdpi
drawable-de-rDE-ldpi
should drawable-de-rDE will be
sufficient?
If you don't feel the need to draw your pictures at the right scale yourself, that should work : android will scale the images to the right size, as needed.
But note that you might get better graphics doing that scaling yourself -- and, instead of just scale up/down, you could re-think your images a little bit, so they fit better in different sizes.
http://developer.android.com/guide/topics/resources/localization.html