双击放大和缩小TouchImageView的功能可以通过实现onDoubleTap
事件来实现。以下是一个简单的示例代码:
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.widget.ImageView;
public class TouchImageView extends ImageView {
private ScaleGestureDetector mScaleDetector;
private Matrix mMatrix;
private float mScaleFactor = 1.f;
public TouchImageView(Context context) {
this(context, null);
}
public TouchImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TouchImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mMatrix = new Matrix();
mScaleDetector = new Scale
领取专属 10元无门槛券
手把手带您无忧上云