3

My android app is working fine with old nexus 7. But I have one issue with new nexus 7 devices. All the dynamic rendering (Image size and Text size) spoil the design like

tv1.setTextSize(getResources().getDimension(R.dimen.legend_text));

here I mentioned 4 folder named as :-

values-large-hdpi
values-large-xhdpi
values-xlarge-hdpi
values-xlarge-mdpi

and in all above folder dimen.legend_text have value 11sp. but when i trace out the value of getResources().getDimension(R.dimen.legend_text) it gives me 18.

here is my log :- 11-18 12:09:29.758: D/size of text foe nexus 7(4794): size of text foe nexus 7 is 18.0

any one have any idea which resource folder is fit for new nexus 7 (1920*1200 resolution).

Praveen Sharma
  • 4,326
  • 5
  • 25
  • 45
  • Why are you so sure, 18px is not the right value for 11sp on your n7? Btw: qualifiers large and xlarge are deprecated since android 3.1 or something. – flx Nov 18 '13 at 06:33
  • I debug it and print the value of `getResources().getDimension(R.dimen.legend_text)` in my log and it shows me as 11-18 12:09:29.758: D/size of text foe nexus 7(4794): size of text foe nexus 7 is 18.0 – Praveen Sharma Nov 18 '13 at 06:40
  • I got that. But why is 18 wrong? You know that sp!=px, right? – flx Nov 18 '13 at 06:43
  • yes right but for old nexus 7 its working fine. and i am not able to find out the exact folder for its resource. from where its taking. – Praveen Sharma Nov 18 '13 at 06:44

2 Answers2

2

Actually you're using 9sp means (px = sp*(dpi/160)) so with this formula px = 9*(320/160) means 18.
This is the reason you're getting the value 18.
In place of 9sp or 11sp keep it 9px and your problem will solve for now.
Regarding folder issue: Use large-xhdpi or sw600dp-xhdpi.

jAC
  • 5,195
  • 6
  • 40
  • 55
Ramesh
  • 46
  • 2
1

tvdpi is the correct folder for nexus 7

Rahul Gupta
  • 5,275
  • 8
  • 35
  • 66