【发布时间】:2021-05-15 01:10:44
【问题描述】:
在下面的代码中,我尝试用 imageView 替换贴纸,保持贴纸的 [宽度、高度、TranslateX、TranslateY 和旋转] 相同imageView:
transX = selectedSticker.getTransX();
transY = selectedSticker.getTransY();
rotation = selectedSticker.getCurrentAngle();
ImageView mHoverView = findViewById(R.id.drawingView);
mHoverView.setLayoutParams(new FrameLayout.LayoutParams((int) stickerWidth, (int) stickerHeight));
mHoverView.setTranslationX(transX);
mHoverView.setTranslationY(transY);
mHoverView.setRotation(rotation);
mHoverView.setImageResource(R.drawable.dog);
mHoverView.setBackgroundColor(Color.BLUE);
当我点击REPLACE按钮将贴纸替换为imageView时,一切正常,问题开始当我旋转时贴纸并点击 REPLACE 按钮,imageView 与贴纸进行相同的旋转,但它设置在错误的位置(imageView 未围绕其中心旋转) :
例如
无旋转:
旋转:
【问题讨论】:
标签: java android android-imageview image-rotation