Question

I have an image of a map which is displayed in my imageview. My image size is 2572*1864 px I want users to see the same "piece" of the map regardless of devices and densities - i.e. my default zoom level should represent same part of the image in px. How do I do that?

I tried the following - calculated that the dimensions of the image piece I want to show is 800px height, and set the default zoom level to - zoomLevel = (devicePxHeight / 800)

But that does not seem to be working and I get different zoom level among devices

Any help appreciated

Was it helpful?

Solution

Probable cause

devicePxHeight/800 

is an integer division

Explicitly make it a floating point operation like so

devicePxHeight*1f/800 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top