@ TargetApi ( Build . VERSION_CODES . JELLY_BEAN_MR1 ) public void show ( ) { ViewGroup parent = ( ViewGroup ) getParent ( ) ; if ( parent == null || mState == STATE_SHOWING || mState == STATE_DISMISSING ) return ; if ( parent instanceof android . widget . FrameLayout ) { LayoutParams params = ( LayoutParams ) getLayoutParams ( ) ; params . width = mWidth ; params . height = mHeight ; params . gravity = Gravity . START | Gravity . BOTTOM ; if ( mIsRtl ) params . rightMargin = mMarginStart ; else params . leftMargin = mMarginStart ; params . bottomMargin = mMarginBottom ; setLayoutParams ( params ) ; } else if ( parent instanceof android . widget . RelativeLayout ) { android . widget . RelativeLayout . LayoutParams params = ( android . widget . RelativeLayout . LayoutParams ) getLayoutParams ( ) ; params . width = mWidth ; params . height = mHeight ; params . addRule ( android . widget . RelativeLayout . ALIGN_PARENT_BOTTOM ) ; params . addRule ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR1 ? android . widget . RelativeLayout . ALIGN_PARENT_START : android . widget . RelativeLayout . ALIGN_PARENT_LEFT ) ; if ( mIsRtl ) params . rightMargin = mMarginStart ; else params . leftMargin = mMarginStart ; params . bottomMargin = mMarginBottom ; setLayoutParams ( params ) ; } if ( mInAnimation != null && mState != STATE_SHOWN ) { mInAnimation . cancel ( ) ; mInAnimation . reset ( ) ; mInAnimation . setAnimationListener ( new Animation . AnimationListener ( ) { @ Override public void onAnimationStart ( Animation animation ) { setState ( STATE_SHOWING ) ; setVisibility ( View . VISIBLE ) ; } @ Override public void onAnimationRepeat ( Animation animation ) { } @ Override public void onAnimationEnd ( Animation animation ) { setState ( STATE_SHOWN ) ; startTimer ( ) ; } } ) ; clearAnimation ( ) ; startAnimation ( mInAnimation ) ; } else { setVisibility ( View . VISIBLE ) ; setState ( STATE_SHOWN ) ; startTimer ( ) ; } }
Show this SnackBar . Make sure it already attached to a parent view or this method will do nothing .