support_ms
support_ms

Reputation: 1933

Zooming and panning TextureView

I tried many examples of how to zoom and pan Views. All they work with different views, imageViews. However I could not find any solution for panning zoomed TextureView. Is there anyone who implemented that feature?

Upvotes: 1

Views: 2945

Answers (1)

support_ms
support_ms

Reputation: 1933

In simple views like ImageView in many implementations canvas is used. Instead of canvas in views whose onDraw() method is final use Matrix. Example:

On ImageView:

 canvas.translate(x, y);
 canvas.scale(mScaleFactor, mScaleFactor);

On TextureView:

 matrix.postTranslate(x, y);
 matrix.postScale(mScaleFactor, mScaleFactor);

Example in github: link

Upvotes: 2

Related Questions