I use the androidsvg-1.2.1.jar for rendering svg image. The original size of the image is 260 pixels in width and 100 pixels in height. I tried to set the width of the image in proportion to the width of the display as follows:
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
height = (int) (width / 2.6);
svg.setDocumentHeight(height);
svg.setDocumentWidth(width);
svg.setDocumentViewBox(0, 0, width, height);
The docs says that methods getDocumentHeight
, setDocumentWidth
and method setDocumentViewBox
accept input values in pixels. But in this case viewbox had estimated size, but the picture itself was located in the left top corner of the viewbox and its size was much smaller than the size of the viewbox (less than about four times).
When I changed the last row of the code as
svg.setDocumentViewBox(0, 0, width/4, height/4);
the size of the picture has become almost equal to the size viewbox, but still remained a little smaller. Why is this happening? And what values should be applied to the input of the setDocumentViewBox
method?