1

I've read a lot about building UI that supports multiple screen resolutions on android. I understand the concept of sp and dp.

Lets say I'm developing a news reader app. I have an list of articles. The list contains small images and titles. Once an item is touched, a bigger version of the image and full article text is visible. The images will be loaded from web. Should I provide biggest available resolution images and rely on the android to scale them when displayed, or should I convert screen densities at runtime to pixels and download images of the appropriate size?

package
  • 4,741
  • 1
  • 25
  • 35

3 Answers3

3

Your answer depends on what YOU think is going to have the most positive or negative impact for the user. This means that you'll have to step outside of your own box for a moment.

Images are some of the most expensive network resources out there, so the first starting point is how large are the images? Next you need to know how large the average screen is that will be using your app. (Often, it is going to be based on your design).

Your download size is image_width X image_height X 4 bytes (failing compression, that is). If your fullscreen images are 1024 X 768 and you have 10 of them, for example, the result is too large to be desirable over 3G network, but a cakewalk over WiFi or 4G. In this case, asking for the appropriate size might be best.

If your images don't even take 1/2 of the screen and they are only loaded one at a time, downloading and resizing it in runtime is best.

Adinia
  • 3,722
  • 5
  • 40
  • 58
Fuzzical Logic
  • 12,947
  • 2
  • 30
  • 58
0

For that use the web view with fill_parent height and width.

Inside the manifest just put below code :

         <supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:resizeable="true"
    android:anyDensity="true" /> 

You can take the reference from below link.

How to make my app full screen on Galaxy Tab

Community
  • 1
  • 1
mayur rahatekar
  • 4,410
  • 12
  • 37
  • 51
  • Answer is not even relevant to package's request. He wants to know what method is best for scaling and what method will result in the least negative impact for both him and his users. – Fuzzical Logic Mar 23 '12 at 08:30
  • @FuzzicalLogic What are you taking about. I think you have not read the Question properly. He wants the application which will run all the screen resolution. which method are you taking about what matters is the solution not a method. If you want you can try above and give the comment. and by the way if have any solution then tell him and me also. if you don't know the solution then at least respect the solution if some one is giving. you just try above and tell me if it is not work. – mayur rahatekar Mar 23 '12 at 08:35
  • No, he asks for the appropriate method a) resize in runtime OR b) resize on server. He is already familiar (and says so) with supporting multiple screens. In addition, he makes no request for tools. He just simply wants to know a) or b) – Fuzzical Logic Mar 23 '12 at 08:38
  • @FuzzicalLogic I hope your solution will help him. Thank you very much. – mayur rahatekar Mar 23 '12 at 08:40
  • Thanks for the answer mayur, but web view is not what I was looking for. – package Mar 23 '12 at 08:43
  • 1
    @Mayur My criticism is not meant to disrespect you, simply to educate you as to correctly interpreting the questioner's needs. You are obviously capable of providing an amazing answer and even adding to my own. You should continue to do so. Merely edit your answer to reflect the user's need and I'll remove my downvote. – Fuzzical Logic Mar 23 '12 at 08:45
  • @FuzzicalLogic Thanks for your criticism next time on wards I will read the question properly an after that only i will give the answer. – mayur rahatekar Mar 23 '12 at 08:48
  • @Mayur Awesome. Can you please simply edit your answer and add a single character or two so I can remove my downvote? :) – Fuzzical Logic Mar 23 '12 at 08:52
0

This is an excerpt from Android developers site

By default, Android scales your bitmap drawables (.png, .jpg, and .gif files) and Nine-Patch drawables (.9.png files) so that they render at the appropriate physical size on each device. For example, if your application provides bitmap drawables only for the baseline, medium screen density (mdpi), then the system scales them up when on a high-density screen, and scales them down when on a low-density screen.

If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density

So if I were you, I wouldn't worry since Android promises to scale down your images.

One best approach would be to test your app on multiple screen sizes, and if you do not find it compatible on some screen size then simply do not include that screen size in your Manifest as indicated by Mayur Rahetkar's answer.

Community
  • 1
  • 1
Arif Nadeem
  • 8,524
  • 7
  • 47
  • 78
  • You are absolutely correct, mirrored. Android does resize images, however, many devs have learned the hard way that if you use this as a way to ignore network, memory or performance impacts, your app will force close quite regularly. In other words, his concern is valid (especially for remote images) – Fuzzical Logic Mar 23 '12 at 09:04
  • Correct me if I'm wrong, but doesn't this section (especially sdpi, mdpi, ldpi) from Android Dev site refers to the drawables you already have included in the project at compile time? – package Mar 23 '12 at 09:05
  • @package: yes you are right, but think it this way, if Android system has the ability to select the appropriate image at runtime and resize it, I don't find a reason why it wouldn't work with images you downloaded. – Arif Nadeem Mar 23 '12 at 09:14
  • 1
    @mirroredAbstraction: are you saying I should force app users to download 4 versions of each image instead of 1? While this is a good concept for compile-time drawables, I don't think it fits when talking about images, downloaded from the web. – package Mar 23 '12 at 09:21
  • you only download 1 image and Android scales it – Arif Nadeem Mar 23 '12 at 09:24
  • @mirrored: And what he is asking (in the original question) is which image to download. The large one or a pre-resized small one. :) – Fuzzical Logic Mar 23 '12 at 09:33
  • 1
    @package&&Fuzzical Logic: This was his actual question "Should I provide biggest available resolution images and rely on the android to scale them when displayed, or should I convert screen densities at runtime to pixels and download images of the appropriate size?", so I had answered my bit, but if you still feel that you should resize it then there are a lot of ways have a look at http://stackoverflow.com/a/9772767/892055 where there is one possible way to scale down your image. – Arif Nadeem Mar 23 '12 at 09:39