我想创建一个应用程序,我想在其中将翻转动画应用于布局。
user2211142
问问题
1522 次
2 回答
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
于 2013-03-26T10:35:43.957 回答
0
你可以试试这个:
增长_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>
收缩到中间.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);
希望这会帮助你。
于 2013-03-26T10:37:31.317 回答