0

So I have been facing this problem for a while and still I cant find solution for it. Hopefully you guys can give me a hand in this. I have a cards game that a player can see his cards like any other cards game.

The problem is that a lot of people complained that cards are too small.When I run it on my devicr (galaxy s2) the cards size are good. By chance someone sent me a screenshot from his HTC and the cards are indeed smaller than What I have.

Please note that I have this 3 different density folders and my Images view are set at wrap content.

I Have 2 solutions in mind and I appreciate if you can help further

1) instead of wrap content, I user a predefined width for each screen size (not density).This will garaunter a specifc size (space it occupies)on large screens for example

2) Make the imageview size relative to the width of the screen.I dont know how to do it so any pointers are appreciated.

3) any suggestions?

please help a programmer stuck in this delemma

Snake
  • 14,228
  • 27
  • 117
  • 250

2 Answers2

1

Do you have images in different sizes for different densities? Which scale type are you using for ImageViews? You can create different layouts for densities but I would start with experimenting with scale types - http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

devmiles.com
  • 9,895
  • 5
  • 31
  • 47
1

You can use DesplayMetrics to get the dimensions of the device at run time and use the width and height you get.

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
int height = metrics.heightPixels;

ImageView iv = (ImageView)findViewById(R.id.yourImageViewId);
iv.setWidth(width);
iv.setHeight(height * 2/3);

or something like that. this way you will never get such issues.

Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
  • Hmm this looks good but do i get always the right values from display matrix. For some reason I heard that this sometimes "lie" – Snake Jul 29 '12 at 18:28
  • http://stackoverflow.com/questions/1016896/android-how-to-get-screen-dimensions#answers-header – Archie.bpgc Jul 30 '12 at 05:36