Tween动画使用注意

<span style="white-space:pre">		</span>    mTitleBar.setTitleImg(R.drawable.arrow_down);
                    mTitleBar.getTitleImgView().setTag(TITLE_IMG_TAG_DOWN);
                    layout.setVisibility(View.VISIBLE);
                    Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.push_top_out);
                    animation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {

                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            shader.setVisibility(View.GONE);
                            layout.setVisibility(View.GONE);
                            layout.clearAnimation();
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });
                    layout.setAnimation(animation);
                    animation.start();


这里最后两行代码的写法有问题,导致动画不能执行,操作了View之后才会执行,下面这种写法误用了。

                    layout.setAnimation(animation);
                    animation.start();


正确的写法:

layout.startAnimation(animation)



<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">


    <translate
        android:duration="200"
        android:fromYDelta="0"
        android:toYDelta="-100%" />
    <alpha
        android:duration="200"
        android:fromAlpha="1.0"
        android:toAlpha="0.0" />
</set>

在这些属性里面还可以加上%和p,例如:
android:toXDelta="100%",表示自身的100%,也就是从View自己的位置开始。
android:toXDelta="80%p",表示父层View的80%,是以它父层View为参照的。


这里的android:toYDelta="0",android:toYDelta="-100%",表示的是,这里取View的左上角那个点进行距离。

左上角点从0,到自身高度比例的100,反方向。也就是View往y轴上方走了自身的高度。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值