1

So everywhere I looked everybody said "multiply your dimensions by getResources().getDisplayMetrics().density. Let me make something clear : I am not trying to draw a bitmap image. Rather a stroked circle.

Paint.setStrokeWidth(20 * scale);

The stroke thickness still looks different on my G3 ( 5.5" 1440x2560 ) and my friend's 5" 1080x1920.

I'm also trying to draw some text and also multiplying the font size with the scale. Why is it looking SO different? ( Stroke is WAY thinner on friends phone and text is WAY smaller ).

EDIT: my scale is getResources().getDisplayMetrics().density

Thanks a lot for your time

Anyone..?

  • Once Im on Linux again, I can tell you what to replace "scale" with, but thats gonna be tomorrow most liikely.. – d0n.key Jan 10 '16 at 19:47
  • I did not reboot to Linux now, but take a look here: http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels - Once you got the dimens, you can code two functions, that will return you a pixel size, once you enter a percentage.. – d0n.key Jan 11 '16 at 16:37

1 Answers1

0

I solved this by using TypedValue.applyDimension.

For the stroke width unit i used TypedValue.COMPLEX_UNIT_DIP, and for the text size i used TypedValue.COMPLEX_UNIT_SP.