public void remove ( final View view ) { if ( view . getParent ( ) instanceof ViewGroup ) { final ViewGroup parent = ( ViewGroup ) view . getParent ( ) ; if ( durationSet ) { view . animate ( ) . setDuration ( duration ) ; } view . animate ( ) . alpha ( 0f ) . setListener ( new AnimatorListenerAdapter ( ) { @ Override public void onAnimationEnd ( Animator animation ) { parent . removeView ( view ) ; view . setAlpha ( 1 ) ; view . animate ( ) . setListener ( null ) ; } } ) ; } }
Fades out the given view and then removes in from its parent . If the view is not currently parented the method simply returns without doing anything .