Android: why setVisibility(View.GONE); or setVisibility(View.INVISIBLE); do not work

前端 未结 11 2146
[愿得一人]
[愿得一人] 2020-12-02 12:51

I want my DatePicker and the button to be invisible in the begining. And when I press my magic button I want to setVisibility(View.Visible);

The problem

11条回答
  •  心在旅途
    2020-12-02 13:20

    This is for someone who tried all the answers and still failed. Extending pierre's answer. If you are using animation, setting up the visibility to GONE or INVISIBLE or invalidate() will never work. Try out the below solution. `

    btn2.getAnimation().setAnimationListener(new Animation.AnimationListener() {
         @Override
         public void onAnimationStart(Animation animation) {
         }
         @Override
         public void onAnimationEnd(Animation animation) {
             btn2.setVisibility(View.GONE);
             btn2.clearAnimation();
         }
         @Override
         public void onAnimationRepeat(Animation animation) {
         }
    });
    

    `

提交回复
热议问题