Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a pivot point while doing rotate animation using object animator in xml in Android?

I am using property animation to rotate a fragment when it goes off screen. Following is my animator xml code:

<set xmlns:android="http://schemas.android.com/apk/res/android" >

<objectAnimator
    android:duration="500"
    android:propertyName="rotationY"
    android:valueFrom="-70"
    android:valueTo="0" >
</objectAnimator>
<objectAnimator
    android:duration="500"
    android:propertyName="alpha"
    android:valueFrom="0"
    android:valueTo="1" >
</objectAnimator>

I want to rotate with the central point of the left edge as the pivot. How to do this?

like image 528
akash Avatar asked Aug 22 '13 05:08

akash


People also ask

What is pivotX and pivotY in Android?

The pivotX and pivotY is the central point of the animation. So for example if you want to do Zoom In animation you can use this <? xml version="1.0" encoding="utf-8"?> <

What is twined animation in Android?

Tween animations are a specific type of animation related to rotation, sliding, and movement of an object. This article explains some common Tween animations. Now we move to the code part of this article. In this article, we will use a single Activity_main. xml.

What are the two different types of view animations property animation and tween animation?

These three types of animation fall into two categories: frame animations and tweened animations. Unsurprisingly, frame-base animations are a type of frame animation, whereas View- and Property-based animations are types of tweened animations.


1 Answers

You can add the:

android:transformPivotX and
android:transformPivotY 

values to the object you want to animate in the layout XML where you created the object (Eg. android:transformPivotX="0dp")

Hope this helps!

like image 54
Akhil K Avatar answered Sep 29 '22 13:09

Akhil K