Java 类android.widget.ZoomButtonsController.OnZoomListener 实例源码

项目:pickncrop    文件:MainActivity.java   
public void createZoomControls() {
    ZoomButtonsController zoomButtonsController = new ZoomButtonsController(
            imageView);
    zoomButtonsController.setVisible(true);
    zoomButtonsController.setAutoDismissed(false);
    zoomButtonsController.setOnZoomListener(new OnZoomListener() {

        public void onZoom(boolean zoomIn) {
            matrix = imageView.getImageMatrix();
            if (zoomIn) {
                matrix.postScale(1.05f, 1.05f, 0.5f * size, 0.5f * size);
                imageView.setImageMatrix(matrix);
            } else {
                matrix.postScale(0.95f, 0.95f, 0.5f * size, 0.5f * size);
                imageView.setImageMatrix(matrix);
            }
            imageView.invalidate();
        }

        public void onVisibilityChanged(boolean visible) {
        }
    });
    RelativeLayout.LayoutParams zoomLayoutParams = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    zoomLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    zoomLayoutParams.addRule(RelativeLayout.BELOW, R.id.imageViewCrop);
    viewManager.addView(zoomButtonsController.getContainer(),
            zoomLayoutParams);
}