When I create the project it comes like this
public class MainActivity extends AppCompatActivity{
Would you like to use more than extends
how to do?
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity implements SimpleOnScaleGestureListener {
private ImageView imageView;
private float scale = 1f;
@Override
public boolean onScale(ScaleGestureDetector detector) {
//Factor de zoom correspondente ao movimento feito
float scaleFactor = detector.getScaleFactor();
//Executa o zoom
performZoom(scaleFactor);
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scaleGestureDetector = new ScaleGestureDetector(this,new MainActivity());
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.performClick();
//Chamar o onTouchEvent do nosso ScaleGestureDetector
scaleGestureDetector.onTouchEvent(event);
return true;
}
});
}
private void performZoom(float scaleFactor) {
scale *= scaleFactor;
scale = Math.max(0.1f, Math.min(scale, 5.0f));
imageView.setScaleX(scale);
imageView.setScaleY(scale);
}
}