翻译动画中的闪烁

时间:2014-07-30 06:59:25

标签: android animation translate-animation

我正在从上到下翻译一个视图并且在动画结束时获得闪烁尝试了许多解决方案但是我没有工作 喜欢 1.最后开始制作小动画。

                                @Override
                                public void onAnimationEnd(Animation animation) {
                                    gallarylayout.setDrawingCacheEnabled(false);
                                    //gallarylayout.clearAnimation();
                                    animation = new TranslateAnimation(0.0f,
                                            0.0f, 0.0f, 0.0f);
                                    animation.setDuration(1);

                                    imageSwitcherlayout
                                            .setVisibility(View.VISIBLE);
                                    bolgDesc.setVisibility(View.VISIBLE);
                                    gallarylayout.startAnimation(animation);
                                    RelativeLayout.LayoutParams layoutParams1 = 
                                            (RelativeLayout.LayoutParams)                          
                                      gallarylayout.getLayoutParams();
                                            layoutParams1.leftMargin = 0;       
                                            layoutParams1.topMargin = 0;
                                            gallarylayout.setLayoutParams(layoutParams1);

                                    // imageSwitcherlayout.setLayoutParams(layoutParams1);

                                }
                            });

2.最后调出清晰的动画。

gallarylayout.clearAnimation();

我的代码是......

slider.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (conuter % 2 == 0) {
                    toTranslate = imageSwitcherlayout.getHeight();
                    TranslateAnimation transAnimation = new TranslateAnimation(
                            0, 0, gallarylayout.getPivotY(), toTranslate);

                    transAnimation.setDuration(1000);
                    //transAnimation.setFillAfter(true);

                    Animation slideUp = AnimationUtils.loadAnimation(
                            getActivity(), R.anim.up);
                    gallarylayout.startAnimation(transAnimation);
                    // Log.e("gallarylayout.getY()", gallarylayout.getY() + "");

                    //slideUp.setFillAfter(true);
                    transAnimation
                            .setAnimationListener(new AnimationListener() {

                                @Override
                                public void onAnimationStart(Animation animation) {
                                    gallarylayout.setDrawingCacheEnabled(true);
                                }

                                @Override
                                public void onAnimationRepeat(
                                        Animation animation) {
                                }

                                @Override
                                public void onAnimationEnd(Animation animation) {
                                    gallarylayout.setDrawingCacheEnabled(false);
                                    //gallarylayout.clearAnimation();
                                    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
                                            FrameLayout.LayoutParams.MATCH_PARENT,
                                            240 + imageSwitcherlayout
                                                    .getHeight());
                                    viewPager.setLayoutParams(layoutParams);

                                    imageSwitcherlayout
                                            .setVisibility(View.GONE);
                                    bolgDesc.setVisibility(View.GONE);
                                    animation = new TranslateAnimation(0.0f,
                                            0.0f, 0.0f, 0.0f);
                                    animation.setDuration(1);
                                    gallarylayout.startAnimation(animation);
                                    RelativeLayout.LayoutParams layoutParams1 = 
                                            (RelativeLayout.LayoutParams) gallarylayout.getLayoutParams();
                                            layoutParams1.leftMargin = 0;       
                                            layoutParams1.topMargin = 0;
                                            gallarylayout.setLayoutParams(layoutParams1);

                                }
                            });
                    conuter++;
                } else {

                    Animation slide = AnimationUtils.loadAnimation(
                            getActivity(), R.anim.down);
                    TranslateAnimation transAnimation = new TranslateAnimation(
                            0, 0, 0, -toTranslate - 10);

                    transAnimation.setDuration(1000);
                    //transAnimation.setFillAfter(false);
                    gallarylayout.startAnimation(transAnimation);

                    slide.setFillAfter(true);
                    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
                            FrameLayout.LayoutParams.MATCH_PARENT, (240));
                    viewPager.setLayoutParams(layoutParams);
                    transAnimation
                            .setAnimationListener(new AnimationListener() {

                                @Override
                                public void onAnimationStart(Animation animation) {
                                    gallarylayout.setDrawingCacheEnabled(true);
                                }

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

                                }

                                @Override
                                public void onAnimationEnd(Animation animation) {
                                    gallarylayout.setDrawingCacheEnabled(false);
                                    //gallarylayout.clearAnimation();
                                    animation = new TranslateAnimation(0.0f,
                                            0.0f, 0.0f, 0.0f);
                                    animation.setDuration(1);

                                    imageSwitcherlayout
                                            .setVisibility(View.VISIBLE);
                                    bolgDesc.setVisibility(View.VISIBLE);
                                    gallarylayout.startAnimation(animation);
                                    RelativeLayout.LayoutParams layoutParams1 = 
                                            (RelativeLayout.LayoutParams) gallarylayout.getLayoutParams();
                                            layoutParams1.leftMargin = 0;       
                                            layoutParams1.topMargin = 0;
                                            gallarylayout.setLayoutParams(layoutParams1);

                                    // imageSwitcherlayout.setLayoutParams(layoutParams1);

                                }
                            });
                    conuter++;
                }
            }
        });

我缺少这种情况下的解决方案?

0 个答案:

没有答案