Grux
Grux

Reputation: 584

Android animation from top right to bottom left using xml

I'm trying to open a dialog from the action bar on the right side. I want to have the animation load from the top right to the bottom left. Here is what I have but it loads from the top left to the bottom right. I've tried to switch it around to no avail. Thanks for any help.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:fromYScale="0" android:toYScale="1.0"
        android:fromXScale="0" android:toXScale="1.0" 
        android:duration="500"/>
</set>

Upvotes: 3

Views: 4076

Answers (2)

KodyVanRy
KodyVanRy

Reputation: 1108

Sorry a couple months late to the game, but the best way and recommended way would be

<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/decelerate_interpolator">
     <scale
            android:fromYScale="0"
            android:toYScale="1.0"
            android:startOffset="0"
            android:duration="1200"
            android:fromXScale="0"
            android:toXScale="1.0"
            android:fillAfter="true"
            android:pivotX="100%" />
</set>

The proper way to do this is using pivot points of where the animation should be coming from

Upvotes: 7

Prasad
Prasad

Reputation: 13

This will be helpful to you.

I tried something like this.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
     android:interpolator="@android:anim/decelerate_interpolator">
    <scale
            android:fromYScale="0"
            android:toYScale="1.0"
            android:startOffset="0"
            android:duration="1200"
            android:fromXScale="0"
            android:toXScale="1.0"
            android:fillAfter="true" />
    <translate android:fromXDelta="100%" android:fromYDelta="-100%"
               android:duration="700" />
</set>

Upvotes: 1

Related Questions