How does dots per inch unit works in android? -
this question has answer here:
- can android support dp's less 1dp? 2 answers
1dp 1 pixel display ppi of 160. why changing small number (0.3) not change visibility? expecting changing 1dp 0.3 dp make widget(just line) invisible.
in android there formula:
px = (int)(scale * dp + 0.5)
(i.e. device density scale rounded nearest whole pixel value)
the scale value based on screen density of device:
so 0.5dp result in {1px, 1px, 1px, 2px} above densities, whereas 1dp {1px, 2px, 2px, 3px}. tiny value 0.1dp resolve {1px, 1px, 1px, 1px} because less 1 in above formula resolves single pixel unless value explicitly 0dp (it's not possible draw thinner single pixel width).
if want ensure thinnest possible width used, best define width explicitly px instead of scaled unit dp. setting value of 1px draw single pixel on devices, , more readable hoping 0.5dp or 0.1dp same.
for more details read documentation
Comments
Post a Comment