0

I've got several markups for different screen sizes. On the same activity, say video, I have to use a ListView element in one case and a GridView element in another. Basically, regarding layout I'll have to switch between logic of either of those two components. What is the best way to achieve it ?

  • so you want to detect screen size and do things accordingly? – C. Leung Apr 25 '12 at 06:32
  • well, probably - I'm also looking for opportunity to use polyporphism. Do you think it is achievable in terms of ListView/GridView/EndlessAdapter ? –  Apr 25 '12 at 06:37

1 Answers1

0

Create your layout folders in res folder and name them as

layout-xlarge for screens are at least 960dp x 720dp
layout-large  for screens are at least 640dp x 480dp
layuot-normal for screens are at least 470dp x 320dp
layout-small  for screens are at least 426dp x 320dp

no need of logic... android will detect automatically and if you want to detect specific dimensions of a device you can try like this..

  Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
5hssba
  • 8,079
  • 2
  • 33
  • 35
  • [See this link..](http://stackoverflow.com/questions/1016896/android-how-to-get-screen-dimensions) – 5hssba Apr 25 '12 at 06:44