我有三个片段,在其中一个片段中我有大约5个不同的imageViews,它们由不同的图像加载。我可以将图像视图拖动到屏幕的所有部分。我现在需要根据用户选择(如捏缩放)实现每个图像视图的缩放。以下代码用于拖动功能的imageview之一 - 其工作正常。
清单
compileSdkVersion 28
defaultConfig {
applicationId "com.austurn.keikonew.keiko"
minSdkVersion 15
targetSdkVersion 28
以下是用于其中一个图像视图的代码。
private int xDelta4;
private int yDelta4;
int xo4;
int yo4;
imgforGlass=(ImageView) getView().findViewById(R.id.imageView12);
imgforGlass.setOnTouchListener(onTouchListener4Glass());
private View.OnTouchListener onTouchListener4Glass() {
return new View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View view4, MotionEvent event) {
view4.invalidate();
final int x4 = (int) event.getRawX();
final int y4 = (int) event.getRawY();
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams)
view4.getLayoutParams();
xDelta4 = x4 - lParams.leftMargin;
yDelta4 = y4 - lParams.topMargin;
break;
case MotionEvent.ACTION_UP:
xo4= (int) event.getX();
yo4= (int) event.getY();
break;
case MotionEvent.ACTION_MOVE:
imgforGlass.getParent().requestDisallowInterceptTouchEvent(true);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)
view4.getLayoutParams();
layoutParams.leftMargin = x4 - xDelta4;
layoutParams.topMargin = y4 - yDelta4;
layoutParams.rightMargin = 0;
layoutParams.bottomMargin = 0;
view4.setLayoutParams(layoutParams);
break;
}
mainLayout.invalidate();
return true;
}
};
}
附件是应用布局.. click here to see the app layout 我需要缩放每个图像视图..
希望我的问题很明确。请帮帮我..