daimajia / AndroidViewAnimations

Cute view animation collection.
MIT License
12.42k stars 2.42k forks source link

set pivot #136

Open rasam29 opened 6 years ago

rasam29 commented 6 years ago

Hello :) thank for the great library 👍 i wanted to know How i can set the pivot of animation to center of my view i already try .pivot(0f,0f) but it doesnt work

KieuQ commented 6 years ago

you might be playing the animation too early

https://stackoverflow.com/a/3594216/4129644

You are calling getWidth() too early. The UI has not been sized and laid out on the screen yet.

I doubt you want to be doing what you are doing, anyway -- widgets being animated do not change their clickable areas, and so the button will still respond to clicks in the original orientation regardless of how it has rotated.

That being said, you can use a dimension resource to define the button size, then reference that dimension resource from your layout file and your source code, to avoid this problem.

https://stackoverflow.com/a/10118459/4129644

We can use

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
//Here you can get the size!
}