我想以编程方式创建一个动画,从触摸屏开始具有缩放效果的活动。
下一步,我模拟了一个缩放输入效果:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator" >
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="0.0"
android:fromYScale="0.0"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>现在我使用上面的动画,从屏幕的中心开始(不是从触摸屏开始,我认为在这种情况下这对用户体验更好)。
overridePendingTransition(R.anim.zoom_enter, android.R.anim.fade_out);我想知道是否可以创建动画,如下所示:
AnimationSet animSet = new AnimationSet(false);
ScaleAnimation zoom = new ScaleAnimation(0, 0, 1, 1, 50, 50);
animSet.addAnimation(zoom);(我会将50,50值替换为适当的值(触摸屏指针)),并将动画设置为overridePendingTransition(int,int)
我见过的所有信息都使用xml转换。
发布于 2014-08-06 23:31:19
我是这样做的:
我在活动的OnCreate方法中创建了ScaleAnimation,设置了它的持续时间,并为根视图启动了它。
Animation anim = new ScaleAnimation(0, 1, 0, 1, mTouchX, mTouchY);
anim.setDuration(mAnimDuration); // duration = 300
getWindow().getDecorView().findViewById(android.R.id.content).startAnimation(anim);它应该在setContentView方法之后
https://stackoverflow.com/questions/22325975
复制相似问题