6

好的,所以我有一个使用以下代码对其进行动画处理的视图:

RelativeLayout rl = (RelativeLayout) findViewById(R.id.productPage_parentLayout_RL);

ImageView iv = new ImageView( ProductPage.this );
imageLoader.DisplayImage(FULL_PRODUCT_INFO.getFirstImage(), iv);

Animation animation = new TranslateAnimation(0, helper.getDeviceWidth() - 100,0, 0);
animation.setDuration(1000);
animation.setFillAfter(true);

rl.addView(iv);

使用此代码,视图从屏幕左侧开始,几乎移动到屏幕的末尾,但我还想淡出视图并最终隐藏/销毁它。我试图搜索与此相关的任何内容,但找不到任何内容。

任何帮助表示赞赏。

4

2 回答 2

10

尝试这个

ObjectAnimator move=ObjectAnimator.ofFloat(iv, "translationY",100f);
                    move.setDuration(3000);
    ObjectAnimator alpha1=ObjectAnimator.ofFloat(iv, "alpha",0.5f);
                    alpha1.setDuration(1000);

                    ObjectAnimator alpha2=ObjectAnimator.ofFloat(iv, "alpha",0);
                    alpha2.setDuration(2000);
    AnimatorSet animset=new AnimatorSet();
                    animset.play(alpha2).before(alpha1).with(move);
                    animset.start();
于 2013-01-02T19:49:14.947 回答
4
    Animation a = new AlphaAnimation(1.0f, 0.0f);
        a.setDuration(1000);
        a.setFillAfter(true);
        iv.startAnimation(a);

AnimationSet set = new AnimationSet(true);
        set.addAnimation(animation)
        set.addAnimation(a)
        set.setFillAfter(true);
        iv.startAnimation(set);

    set.setAnimationListener(new AnimationListener() {

                    public void onAnimationStart(Animation animation) {
                        // TODO Auto-generated method stub

                    }

                    public void onAnimationRepeat(Animation animation) {
                        // TODO Auto-generated method stub

                    }

                    public void onAnimationEnd(Animation animation) {
                        iv.setVisibility(View.INVISIBLE);

                    }
                });
于 2013-01-02T17:20:19.463 回答