我想创建一个应用程序,我想在其中应用翻转动画进行布局。
答案 0 :(得分:1)
private void applyRotation(float start, float end) {
// Find the center of image
final float centerX = image1.getWidth() / 2.0f;
final float centerY = image1.getHeight() / 2.0f;
// Create a new 3D rotation with the supplied parameter
// The animation listener is used to trigger the next animation
final Flip3dAnimation rotation =
new Flip3dAnimation(start, end, centerX, centerY);
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new AccelerateInterpolator());
rotation.setAnimationListener(new DisplayNextView(isFirstImage, image1, image2));
if (isFirstImage)
{
image1.startAnimation(rotation); // "YourLayout"
} else {
image2.startAnimation(rotation); // "Your Other Layout"
}
}
查看本教程,它完全符合您的要求。 http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html
答案 1 :(得分:0)
你可以试试这个:
Grow_from_middle.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
android:duration="200"
android:fillAfter="false"
android:fromXScale="0.0"
android:fromYScale="0.7"
android:interpolator="@android:anim/linear_interpolator"
android:startOffset="200"
android:toXScale="1.0"
android:toYScale="1.0" />
<translate
android:duration="200"
android:fromXDelta="50%"
android:startOffset="200"
android:toXDelta="0" />
</set>
shrink_to_middle.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
android:duration="200"
android:fillAfter="false"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="0.0"
android:toYScale="0.7" />
<translate
android:duration="200"
android:fromXDelta="0"
android:toXDelta="50%" />
</set>
将此用作:
overridePendingTransition(R.anim.grow_from_middle,R.anim.shrink_to_middle);
希望这会对你有所帮助。