1

I have an Activity with Grid View with 4 images. My Application focus on above Android version 3 and both Tablets and mobile. I want to know what is the actual image size i want to design to fit all screens. For example,What is the best image size for 7 inch tablet? In developer document said, based on dip , but i need actual each image size to fit on grid view(4 images) in 7 inch tablet.

Ramprasad
  • 7,981
  • 20
  • 74
  • 135
  • If you are trying to fit four images on GridView no matter the screen size you have to do it using the actual screen size and set image's width and height depending on your calculations. – hardartcore Feb 19 '13 at 09:40
  • Just use fill-parent and wrap-content in your gridview and images will be set inside that grids. – Manish Dubey Feb 19 '13 at 09:44
  • http://www.hdri.at/dpirechner/dpirechner_en.htm Check this , from here you can make drawable size – Manish Dubey Feb 19 '13 at 09:45

2 Answers2

2

in this case you have to create different layouts of your mainlayout. for an example . for 5.1 phones such as Galaxy Note you have to create new folder name it as layout-large and for 7.0 to 10.1 tablets you have to create new folder called layout-xlarge after creating these both folder paste your main xml inside them , and you'll see how your layout will look at 5.1 and tablets. this is the best way i came cross to make my images , layouts fits on all the screens. hope that helps you.

Kosh
  • 6,140
  • 3
  • 36
  • 67
-1

Dip x screen density = pixels (actual image size)

dp to px formula

displayMetrics = context.getResources().getDisplayMetrics();
return (int)((dp * displayMetrics.density) + 0.5); 

As answered by Bram.

Fahad Ishaque
  • 1,916
  • 1
  • 17
  • 21
  • I have confused with dp and actual pixel pixels.To support different screens i need drawbles in different sizes, how to find the suited drawble size for different screens. My doubt is, if i put a same size image for all density buckets,then image quality will be low? – Ramprasad Feb 21 '13 at 02:55
  • DP is Relative Pixel type of thing, its only an android unit. How it works = for example 35dp is same across all 7 inch devices, irrespective of their densities.35px (pixels) differ on different screen densities. – Fahad Ishaque Feb 21 '13 at 06:09
  • Highest density screen in 7inch category is Nexus 7. Its screen size is 1280x800. So your image should be 320x200. In this way it would fit Nexus 7. You can define weights also. – Fahad Ishaque Feb 21 '13 at 06:09
  • Actually i developing an Activity for 7" and 10" tablets. In this Activity i used Grid View with 4 images.This occupies whole screen.So what size of image i want to design in designing software to fit all 7" and 10" tablets.How do you find the actual image size from screen size or dp. Is there any document available? – Ramprasad Feb 21 '13 at 06:25
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/24872/discussion-between-fahad-ishaque-and-ram) – Fahad Ishaque Feb 21 '13 at 06:27
  • hello @FahadIshaque how did you calculate image size according to the screen size... – Dory Mar 13 '13 at 10:43
  • Can you please explain/describe a bit more. – Fahad Ishaque Mar 13 '13 at 13:19