0

I have an html page that I am showing on an Android WebView Control.

However, I need to make sure that the margin, and size is as same as DP and SP specs given by the design team.

How can I confirm DP to % that I can use for scaled styling in HTML/css?

Also how can do the same with SP unit?

So for e.g. if I want my text font size to be 17 sp. Then what should be the corresponding version in %. Similarly, if the margin is expected as 64 dp then how I should calculate the corresponding percentage.

Thanks for your help.

codebased
  • 6,945
  • 9
  • 50
  • 84

1 Answers1

0

I suggest add meta name="viewport" content="width=device-width, initial-scale=1">, then your html 100% width has device-width pixels. like in a 320X640 cellphone, 100% width is 320px, in css.

for converting between dp and px, refer to What is the difference between "px", "dp", "dip" and "sp" on Android?

for converting %: N% = a/b x 100%.

so convert 64(dp) to N(px), and to N(px)/device-width x 100%, is the final result.

Community
  • 1
  • 1
Jiang YD
  • 3,205
  • 1
  • 14
  • 20
  • thanks that I already have one but that does not answer my question about converting the value of 64 dp to a corresponding %. – codebased Aug 21 '15 at 06:13