I have:
- A Dialog with an webview in it. The dialog can have different sizes on the screen.
- I have a html in the webview with an image tag and size properties.
What I want:
- I would like to have the picture with a size of 1 cm (Centimeter) square. How can I achieve this ? I realized that the size of width and height of the image tag is not equal to pixels in my case. If I set the width of the image to the screensize, then the picture is displayed much larger then the screenwidth.
Code: Cm in Pixel:
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
fDensityDpi = metrics.densityDpi;
float pixelperinch = getfDensityDpi();
float inchpercm = 1.0f / 2.54f;
pixelPerCm = (int) (inchpercm * pixelperinch + 0.5);
Content for the webview:
"<img width=\"" + pixelPerCm + "\" height=\"" + pixelPerCm + "\" src=\"" + imagePath + "\" " + sStyle + ">"
The size of the picture on the device is not the expecting 1 cm.
Can someone help me howto size in Image in a webview to exactly one cm on every device ?