1

How to design proper layout or provide different margin,width and height for two different device i.e 3.2'' HVGA Slider (ADP1) (320X480;mdpi) and Nexus One (3.7'',480X800;hdpi) using values folder, because both devices access same value folder but look is not same.

Shailesh
  • 11
  • 4

1 Answers1

0

According to doc both devices will really access the same folder. I had similar issue some time ago and I used this code:

DisplayMetrics metrics = context.getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;

and after you can make conditions like

if(width>=320 && width<480){
    yourView.setTextSize(myTextSize); //or use LayoutParams to define more options

or use switch/case operator instead

This is how I solved it, but if you have many many view elements, could be not useful.

Yurets
  • 3,999
  • 17
  • 54
  • 74