-결과-

 

 

-구조-

 

 

 

-전체코드-

- activity19_main.xml

 

- translate_up.xml

 

- translate_down.xml

 

- Activity19.java

public class Activity19 extends AppCompatActivity {
    Animation translateUp;
    Animation translateDown;

    LinearLayout menuContainer;

    boolean isshown = false;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity19_main);

        translateUp = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.translate_up);
        translateDown = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.translate_down);

        translateUp.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // 애니메이션 끝나는 시점
                menuContainer.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        menuContainer = findViewById(R.id.menuContainer);

        Button button = findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(isshown){
                    menuContainer.startAnimation(translateUp);
                }else { // 보이도록
                    menuContainer.setVisibility(View.VISIBLE);
                    menuContainer.startAnimation(translateDown);
                }

                isshown = !isshown;  // !<-반대로 바꿔주는거 (boolean이니깐)
            }
        });

        
    }
}