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

  • Replies:8
  • OpenNot stickiedUnanswered
  • Forum posts: 5

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:

Deactivated Account
  • Forum posts: 41

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

  • Forum posts: 5

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

Thanks friend for reply but i googled it no improvement.

I want to single finger touch and rotate.
Deactivated Account
  • Forum posts: 41

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
  • Forum posts: 41

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 ?
  • Forum posts: 5

Apr 11, 2014 11:04:29 AM via Website

Hi The posted link is for ios but i need for android.
Deactivated Account
  • Forum posts: 41

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.
  • Forum posts: 1

May 11, 2015 3:01:31 PM via Website

Hi Shanmugapriyan,

I am also looking for the same functionality in android to rotate sticker (like in aviary app) with single touch. Just wondering did you get any solution and if yes can you please share with me?