Android: show/hide a view using an animation

后端 未结 9 2064
青春惊慌失措
青春惊慌失措 2021-01-30 00:53

I\'ve been looking through many google results / questions on here to determine how to show/hide a view via a vertical animation, but I can\'t seem to find one that\'s exactly r

9条回答
  •  执念已碎
    2021-01-30 01:16

    ViewAnimator:

    In XML:

      
    
        
    
        
    
        
    
    
    

    Functions:

    public void show(int viewId) {
        ViewAnimator animator = (ViewAnimator) findView(animatorId);
        View view = findViewById(viewId);
    
        if (animator.getDisplayedChild() != animator.indexOfChild(view)) {
            animator.setDisplayedChild(animator.indexOfChild(view));
         }
     }
    
    
     private void showAuthenticationConnectionFailureMessage() {
        show(R.id.text_message_authentication_connection);
    }
    

提交回复
热议问题