BekaKK
BekaKK

Reputation: 2243

Android view move up/down with TranslateAnimation

i try to move view up and the down.i wrote code witch can move my view up and now i want write code to move this view down and the invisible this view this is a move up code

comment.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            TranslateAnimation anim=new TranslateAnimation(0,0,100,0);
            anim.setFillAfter(true);
            anim.setDuration(1500);    
            comment_layout.setEnabled(true);
            comment_layout.startAnimation(anim);
            close_popap.setVisibility(View.VISIBLE);
            comment_layout.setVisibility(View.VISIBLE);             
        }
    });

i also wrote move down source but i it is not working.i have doing something wrong

 close_popap.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                close_popap.setVisibility(View.GONE);
                TranslateAnimation anim=new TranslateAnimation(0,0,-100,0);
                anim.setFillAfter(true);
                anim.setDuration(1500);      
                comment_layout.setEnabled(true);
                comment_layout.startAnimation(anim);
                close_popap.setVisibility(View.GONE);
                comment_layout.setVisibility(View.GONE);

            }
        });

what am i doing wrong?if anyone knows solution please help me thanks

Upvotes: 0

Views: 1906

Answers (1)

Ratul Ghosh
Ratul Ghosh

Reputation: 1500

try this -

        close_popap.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            close_popap.setVisibility(View.GONE);
            TranslateAnimation anim=new TranslateAnimation(0,0,0,100);
            anim.setFillAfter(true);
            anim.setDuration(1500);
            anim..setAnimationListener(new AnimationListener()
            {

                @Override
                public void onAnimationStart(Animation animation)
                {

                }

                @Override
                public void onAnimationRepeat(Animation animation)
                {

                }

                @Override
                public void onAnimationEnd(Animation animation)
                {
                      close_popap.setVisibility(View.GONE);
                      comment_layout.setVisibility(View.GONE);
                }
            });

            comment_layout.setEnabled(true);
            comment_layout.startAnimation(anim);


        }
    });

Upvotes: 1

Related Questions