0

I know this kind of question has been asked many times but none of them helped me.

I want different integer values for my 4, 5 and 5.5 inch devices. For that I have created different values folder like values-small, values-normal and values-large

But every time I am getting value from values-normal only. None of this work for me.

I have also tired to calculate minimum width using following formula. To get minimum width and create folder accordingly.

DisplayMetrics dm = this.getApplicationContext().getResources().getDisplayMetrics();
float screenWidth = dm.widthPixels / dm.density;
float screenHeight = dm.heightPixels / dm.density;

Still I am getting same result. Please help me to figure this out.

My testing devices are HTC ONE X(4.7 inch), Moto G3(5 inch) amd Meizu MX5 (5.5 inch)

H Raval
  • 1,903
  • 17
  • 39

2 Answers2

2

Try creating folder as below.

res/values/dimens.xml(default)
res/values-ldpi/dimens.xml   (240x320 and nearer resolution)
res/values-mdpi/dimens.xml   (320x480 and nearer resolution)
res/values-hdpi/dimens.xml   (480x800, 540x960 and nearer resolution)
res/values-xhdpi/dimens.xml  (720x1280 - Samsung S3, Micromax Canvas HD, etc) 
res/values-xxhdpi/dimens.xml (1080x1920 - Samsung S4, HTC one, etc)

it's working fine for me

Rissmon Suresh
  • 13,173
  • 5
  • 29
  • 38
0

I dont know why but i was getting same smallest width for my HTC (4.7) and Moto3G (5). So i switched to heard coding it.

well for now i have solved this with the help of this. I am calculating smallest width at run time and get my desired output using if..else. I dont know this is the best solution or not, but working for me at this time.

Looking for batter solution or suggestion.

Community
  • 1
  • 1
H Raval
  • 1,903
  • 17
  • 39