Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

android - animation to transition between views with rotation on z-axis with depth perception

I'm trying to create an animation to transition between two views, both of which are ExpandableListViews. The look I want is described in the image below.

I tried using a shrink_to_middle and grow_from_middle as the out/in animations of my ViewAnimator - and it's close, but not quite right - with my current shrink/grow, as the animation is taking place, both the right and left edges of the views are the same height, which does not provide any depth to the animation.

I'm not sure how best to explain what I want, which is why I drew the image, but here goes anyways... I want to have a 3-d look to the animation where the view is rotated on the z-axis. Assuming we use a simple shrink_to_middle and grow_from_middle animation as the starting point (which does not provide a 3-d look.) To provide the 3-d look, the out animation would have the right edge get progressively smaller as the view shrinks to the middle; the in animation would have the left edge get progressively larger as the view grows from the middle.

Images 1 through 4 would be the out animation (for view #1) and images 5-8 would be the in animation (for view #2)

animation to transition between views

Thanks in advance.

Edit: FYI, Here are my current shrink to middle and grow from middle animation xml files

shrink_to_middle.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="1.0" android:toXScale="0.0" android:fromYScale="1.0"
        android:toYScale="1.0" android:fillAfter="false" android:duration="500" />
    <translate android:fromXDelta="0" android:toXDelta="50%"
        android:duration="500" />
</set>

grow_from_middle.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="0.0" android:toXScale="1.0" android:fromYScale="1.0"
        android:toYScale="1.0" android:fillAfter="false" android:startOffset="200"
        android:duration="500" />
    <translate android:fromXDelta="50%" android:toXDelta="0"
        android:startOffset="200" android:duration="500" />
</set>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Rotate3dAnimation is the answer. It is in the samples SDK folder. I'm using out animation of 0 to -90 and in animation of 90 to 0 and it works great.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...