任何人都可以帮助我用2个手指触摸缩放(调整大小)图像吗?我有frameLayout,我动态追加imageViews。我想缩放图像。我可以在不使用Matrix的情况下解决这个问题吗?
移动正常工作我在frameLayout上移动图像。但缩放不知道。你能给我一些链接或图书馆如何解决这个问题?我找到了一些解决方案,但问题是规模只在imageView中起作用。 framelayout和imageView。 ImageView必须具有width_parent的宽度和高度,你可以在这个imageView中缩放和移动图像。但是我希望在这个FrameLayout中扩展ImageView。我把我的代码和这个工作正常,当我添加3个图像,我可以处理这个图像单。但我还需要调整大小。感谢您的帖子
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_selected_images_per_category);
Intent intent = getIntent();
selectedImages = intent.getParcelableArrayListExtra("selectedImages");
relativeLayout = (FrameLayout) findViewById(R.id.customLayutForImages);
for(int i=0; i< selectedImages.size(); i++) {
ImageView mImageView = new ImageView(SelectedImagesActivity.this);
Uri u = selectedImages.get(i);
mImageView.setImageURI(u);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( 300,300 );
relativeLayout.addView(mImageView, params);
mImageView.setOnTouchListener(this);
}
enter code public boolean onTouch(View view, MotionEvent event) {
final int X = (int) event.getRawX();
final int Y = (int) event.getRawY();
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
FrameLayout.LayoutParams lParams = (FrameLayout.LayoutParams) view.getLayoutParams();
_xDelta = X - lParams.leftMargin;
_yDelta = Y - lParams.topMargin;
mode = MOVE;
break;
case MotionEvent.ACTION_UP:
break;
case MotionEvent.ACTION_POINTER_DOWN:
mode = ZOOM;
break;
case MotionEvent.ACTION_POINTER_UP:
break;
case MotionEvent.ACTION_MOVE:
if (mode == ZOOM) {
//WHAT TO DO HERE
}
if (mode == MOVE) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view
.getLayoutParams();
layoutParams.leftMargin = X - _xDelta;
layoutParams.topMargin = Y - _yDelta;
layoutParams.rightMargin = -250;
layoutParams.bottomMargin = -250;
view.setLayoutParams(layoutParams);
}
break;
}
relativeLayout.invalidate();
return true;
}here