Android ImageView dynamically scales pictures with gestures

In the actual project development of Android, ImageView is often used. If it is purely used to display a picture, this native component is very convenient. But sometimes in order to make the effect more dazzling, such as the processing of pictures in many software, we need to do some processing on the native ImageView to achieve the desired effect. The principle is the application of matrix and PointF. In fact, it is not difficult to understand the latter. We need to write a class to inherit ImageView to realize the functions we want. What I demonstrate here is that the class name is scaleimageview, which mainly rewrites the ontouchevent method to monitor the changes of gestures, so as to process pictures. Not much to say. Stick it out and copy it in the past.

After this class is written, its usage is the same as that of the native ImageView, but in this way, the image can be scaled without any processing. The usage is as follows:

Special attention should be paid here to the configuration of Android: scaletype = "matrix". Scaletype must be of matrix type, otherwise it will become invalid. Anyone who wants to achieve this effect must be set to matrix type. Well, here, it's OK to realize the dynamic scaling of images by ImageView. I hope this article will be helpful to your study.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>