android-collage-views icon indicating copy to clipboard operation
android-collage-views copied to clipboard

How to get the view's position after translation and scale?

Open SwordBearer opened this issue 10 years ago • 3 comments

Could you tell me how to calculate the view's position after translated/Scaled ? I know view.setTranslationX() and view.setTranslationY() don't change the view's real position( because the view's getLeft() and getTop() are not change), but after being dragged and scaled, How to get the visual position (such as get the distance to parent's left and top)?

SwordBearer avatar Dec 01 '14 06:12 SwordBearer

Getters for translateX, translateY, scaleX, and scaleY.

thuytrinh avatar Dec 01 '14 08:12 thuytrinh

Hey :-)

First of all, thanks for a cool lib!

Second, I have a use case where I need help with this as well. I need to move the stickers in a layout in one view, save the state of them, and redraw them in with the same transformations in another canvas.

I thought saving the TransformInfo object and calling the move() method in the MultiTouchListener with it would do the trick, but apparently not

  • The TransformInfo object is not affected when simply moving the image, only when scaling/rotating.
  • Even if I have scaled and/or rotated an image and therefore have a TransformInfo object to pass to a new instance of MultiTouchListener to call move() with, nothing happens.

Any ideas how to do this? Thanks :-)

EDIT: And there doesn't seem to be any other values for translateX, translateY, scaleX, and scaleY as mentioned in 2014 :-) I'm guessing they have since been moved into the TransformInfo object?

jhalborg avatar Jul 06 '16 11:07 jhalborg

Hello,

As SwordBearer, I tried to get translate and scale values. I do this job in MotionEvent.ACTION_UP case in onTouch method of MultiTouchListener. No problem for this. After moving and scaling my view, I do a first screen capture in order to obtain a perfect image of the view state. Ok, that's done.

In a second time, I restart app and apply previous found values to the view with setTranslateX, setTranslateY, setScaleX and setScaleY. I do a second capture. But what is very strange when comparing the 2 captures is that view position is not exactly corresponding while size is correct.

Any idea ?

Thanks.

David

dupuisdavid avatar Sep 14 '16 16:09 dupuisdavid