我正在尝试制作一个动画,它将从当前位置滑动到屏幕中心然后翻转.我让每个移动组件都正常工作但是一旦我将它们全部放入具有startoffset的集合中,动画就不会启动,直到该偏移结束并且它立即执行所有动画.对此有任何帮助非常感谢.
slide_down.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Slide down -->
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="1000"/>
<!-- Set alpha to fully opaque -->
<alpha
android:fromAlpha="0.8"
android:toAlpha="1.0"
android:duration="1000" />
<!-- Flip image once it's in the center -->
<!-- ***** HERE IS THE only offset I set ****** -->
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:pivotX="50%"
android:fromYScale="1.0"
android:toYScale="1.0"
android:startOffset="1000"
android:duration="200" />
</set>
Run Code Online (Sandbox Code Playgroud)
调用代码
Animation anim = AnimationUtils.loadAnimation(getActivity(), slideDirection);
anim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
mCallBack.categorySelected(view.getId());
}
});
view.clearAnimation();
view.startAnimation(anim);
Run Code Online (Sandbox Code Playgroud)
谢谢,德曼
动画偏移始终从动画开始处计算。如果你想让你的动画一张一张地播放,那么你必须自己计算偏移量。
下面将播放翻译 1 秒,然后播放 alpha 1 秒,然后播放 200 毫秒的缩放 -
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Slide down -->
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="1000"/>
<!-- Set alpha to fully opaque -->
<alpha
android:fromAlpha="0.8"
android:toAlpha="1.0"
android:startOffset="1000"
android:duration="1000" />
<!-- Flip image once it's in the center -->
<!-- ***** HERE IS THE only offset I set ****** -->
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:pivotX="50%"
android:fromYScale="1.0"
android:toYScale="1.0"
android:startOffset="2000"
android:duration="200" />
</set>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8774 次 |
| 最近记录: |