Resize, rotate or move any view with single touch in android

  • Replies:7
  • OpenNot stickiedUnanswered

Apr 11, 2014 7:01:02 AM via Website

I am currently developing an application which will allow user to add stickers (hat, hairs, spectacles etc) on image. User can resize that sticker or can rotate that and move also.

Refer link for IOS:
digthebit.com/blog/

Thanks,
Shanmugapriyan.

Deactivated Account

Apr 11, 2014 7:38:40 AM via Website

why don't you go for layout animation ?
you can rotate , move , blur ..lot of things..Just Google it :)

:blink:

Deactivated Account

Apr 11, 2014 8:02:31 AM via Website

Ok , first of all , you need to implement touchListner.
You get touch ordinates from that. you need to detect if user had pressed finger and is in pressed state not lifted up. You can do that using Boolean variable.
when user slide finger , touch co-ordinate changes. You need to pass co-ordinate to animator class so that it can perform animation.
For rotate you need to detect angle from change in coordinates then with that angle u have to start rotate animation.

How to get angle ?
center of the view is the reference coordinate. You have x ,y (old x y location coordinate noted down when user touched the screen) and new one (x1, y1) (that keeps changing when user slides down)

Now you know center of the view , old coordinate and new one. Image a circle having center as center of view. using simple mathematics you can detect angle. Then tell animator to rotate view with that angle. But make sure since user can slide fast and every time animator class loads ,you need to optimize code based for performance.

You have to write your own algorithm is there is not API in market.
Have a happy coding !

Deactivated Account

Apr 11, 2014 8:08:37 AM via Website

Just saw the link you posted. Its sounds the same. I think you got the code. What is the blocker for you ?

Deactivated Account

Apr 14, 2014 6:33:40 AM via Website

If you want a readymade code ,
I would like to suggest you to try a tool that converts embedded c code into java code. But still you have to do some modifications.