Android анимирует мою относительную компоновку снизу вверх и сверху вниз, используя анимацию перевода при просмотре изображений

Мне нужно анимировать мою относительную компоновку, когда вы нажимаете на изображение.

1. Перемещение относительного макета снизу вверх (при нажатии на него в режиме просмотра изображения).

2.Перемещение сверху вниз (при повторном нажатии на него в режиме просмотра изображения).

Сначала, когда я нажимаю на изображение, этоS отлично работает, а относительная компоновка перемещается снизу вверх, но когда я снова нажимаю на изображение, оно отображается 'Анимация сверху вниз, когда этодобрался до первоначального положения этоs скрыть мою деятельность .. любую помощь и заранее спасибо.

Это моя активность:

 public class MainActivity extends Activity {

RelativeLayout rl_footer;
ImageView iv_header;
boolean isBottom = true;
Button btn1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    rl_footer = (RelativeLayout) findViewById(R.id.rl_footer);
    iv_header = (ImageView) findViewById(R.id.iv_up_arrow);
    iv_header.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            iv_header.setImageResource(R.drawable.down_arrow);
            // iv_header.setVisibility(View.INVISIBLE);
            // iv_down.setVisibility(View.VISIBLE);
            iv_header.setPadding(0, 10, 0, 0); // substitute parameters for
                                                // left, top, right, bottom
            rl_footer.setBackgroundResource(R.drawable.up_manu_bar);
            // FooterAnimation();

            if (isBottom) {
                FooterAnimation();
                isBottom = false;
            } else {
                iv_header.setImageResource(R.drawable.up_arrow);
                iv_header.setPadding(0, 0, 0, 10);
                rl_footer.setBackgroundResource(R.drawable.down_manu_bar1);
                headerAnimation();
                isBottom = true;
            }

        }
    });

}

public void FooterAnimation() {
    Animation slide = null;
    slide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, -5.0f);

    slide.setDuration(400);
    slide.setFillAfter(true);
    slide.setFillEnabled(true);
    rl_footer.startAnimation(slide);

    slide.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {

            rl_footer.clearAnimation();

            if (isBottom) {
                RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                        rl_footer.getWidth(), rl_footer.getHeight());
                lp.setMargins(rl_footer.getWidth(), 0, 0, 0);
                rl_footer.setLayoutParams(lp);
            } else {
                RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                        rl_footer.getWidth(), rl_footer.getHeight());
                lp.setMargins(0, 0, 0, 0);
                rl_footer.setLayoutParams(lp);
            }

        }

    });

}

public void headerAnimation() {

    Animation slide = null;
    slide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 5.2f);

    slide.setDuration(400);
    slide.setFillAfter(true);
    slide.setFillEnabled(true);
    rl_footer.startAnimation(slide);

    slide.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {

            rl_footer.clearAnimation();

            if (isBottom) {
                RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                        rl_footer.getWidth(), rl_footer.getHeight());
                lp.setMargins(rl_footer.getWidth(), 0, 0, 0);
                rl_footer.setLayoutParams(lp);
            } else {
                RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                        rl_footer.getWidth(), rl_footer.getHeight());
                lp.setMargins(0, 0, 0, 0);
                rl_footer.setLayoutParams(lp);
            }

        }

    });

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

 }

и мой XML:

 




    

    

    

    

    

    

    

    

    

    
 


Ответы на вопрос(1)

Ваш ответ на вопрос