Is there a way to set the scale for TouchImageView in Android?

Like many other users, I am using the TouchImageView class available at https://github.com/MikeOrtiz/TouchImageView

In my application, I am loading image files that come from a service that I have installed into my TouchImageView object. This works great as I can zoom in and pan the image. However, whenever I press one of my buttons to move to the next or previous image, the image will be zoomed in to the standard scaling before the next image is displayed. This is the first question.

The TouchImageView returns to its original zoom level anytime another component is updated. Just calling this next line of code in the EditText resets the scale.

imagePageNumber.setText(imagePageNumber.getText());

      

To work around this, I tried to keep the current zoom level information before it was lost and then reapply it after the image was loaded. I wrote a touchZoom (float mScaleFactor) method in the TouchImageView that basically mimics the scaling behavior of the existing onScale method. If I call this directly after updating my image with imageView.setImageBitmap (bm), the image is not scaled. If, however, I have a button listening for clicks on the button and trying to scale after the image is loaded, it will correctly update the scale to the value I saved earlier. My guess is that there may be a problem with how the image is loaded and cannot scale instantly after calling the setImageBitmap function.

Does anyone know how to keep the scale from one image to another?

+3


source to share





All Articles