thuytrinh / android-collage-views

Draggable, rotatable, and scalable views for Android
332 stars 88 forks source link

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

Open SwordBearer opened 9 years ago

SwordBearer commented 9 years ago

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)?

thuytrinh commented 9 years ago

Getters for translateX, translateY, scaleX, and scaleY.

jhalborg commented 8 years ago

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

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?

dupuisdavid commented 8 years ago

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