所以我在图像视图上做一些旋转和翻译。据我了解,图像视图在其中任何一个之后都不是真正位于新位置,您必须在动画完成后将其实际移动到那里。所以我试图移动的图像视图被称为令牌,它被设置在它的原始位置并token.getLocationOnScreen( tokenPos );
有它的起始位置。移动或平移后,我调用resetToken
以处理移动或旋转。这似乎在一半的时间内完成了预期的结果......不确定我做错了什么,但它与它面对我想要的方式不一致。
public void resetToken() {
//Decode Image using Bitmap factory.
Bitmap bMap = Bitmap.createBitmap(token.getDrawingCache());
Matrix matrix = new Matrix();
matrix.postRotate(0);
//move the token to the spot it needs to be in
//after an animation the token is not really
//in the new spot
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(token.getWidth(), token.getHeight());
lp.setMargins(tokenPos[0], tokenPos[1], 0, 0);
//Create bitmap with new values.
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, token.getWidth(), token.getHeight(), matrix, true);
token.setImageBitmap(bMapRotate);
token.setLayoutParams(lp);
//put rotated image in ImageView.
moveCounter = moveCounter + 1;
}