public void show(){
  final int height=buildDropDown();
  final int widthSpec=getListWidthSpec();
  boolean noInputMethod=isInputMethodNotNeeded();
  PopupWindowCompat.setWindowLayoutType(mPopup,mDropDownWindowLayoutType);
  final int marginsLeft=mMargins.left;
  final int marginsTop=mMargins.top;
  final int marginsBottom=mMargins.bottom;
  final int marginsRight=mMargins.right;
  getBackgroundPadding(mTempRect);
  final int backgroundLeft=mTempRect.left;
  final int backgroundTop=mTempRect.top;
  final int backgroundBottom=mTempRect.bottom;
  final int backgroundRight=mTempRect.right;
  int verticalOffset=mDropDownVerticalOffset;
  int horizontalOffset=mDropDownHorizontalOffset;
  final int anchorWidth=mDropDownAnchorView.getWidth();
  final int anchorHeight=mDropDownAnchorView.getHeight();
  getLocationInWindow(mDropDownAnchorView,mTempLocation);
  final int anchorLeft=mTempLocation[0];
  final int anchorRight=anchorLeft + anchorWidth;
  final int anchorTop=mTempLocation[1];
  final int anchorBottom=anchorTop + anchorHeight;
  final boolean rightAligned=GravityCompat.getAbsoluteGravity(getDropDownGravity() & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK,mLayoutDirection) == Gravity.RIGHT;
  if (rightAligned) {
    horizontalOffset+=anchorWidth - widthSpec - (marginsRight - backgroundRight);
  }
 else {
    horizontalOffset+=(marginsLeft - backgroundLeft);
  }
  final int bottomDecorations=getWindowFrame(mDropDownAnchorView,noInputMethod,mTempRect);
  final int windowLeft=mTempRect.left;
  final int windowRight=mTempRect.right;
  final int windowTop=mTempRect.top;
  final int windowBottom=mTempRect.bottom;
  final int windowWidth=windowRight - windowLeft;
  final int windowHeight=windowBottom - windowTop;
  getBoundsInWindow(mTempRect);
  final int boundsTop=mTempRect.top;
  final int boundsRight=mTempRect.right;
  final int boundsLeft=mTempRect.left;
  final int boundsBottom=mTempRect.bottom;
  final int screenRight=windowRight - (marginsRight - backgroundRight) - boundsRight;
  final int screenLeft=windowLeft + (marginsLeft - backgroundLeft) + boundsLeft;
  final int screenWidth=screenRight - screenLeft;
  if (!rightAligned && windowWidth < anchorLeft + horizontalOffset + widthSpec) {
    horizontalOffset=mDropDownHorizontalOffset < 0 ? 0 : mDropDownHorizontalOffset;
    horizontalOffset-=widthSpec - (windowWidth - anchorLeft);
    horizontalOffset-=marginsRight - backgroundRight;
  }
 else   if (rightAligned && 0 > anchorLeft + horizontalOffset) {
    horizontalOffset=mDropDownHorizontalOffset > 0 ? 0 : mDropDownHorizontalOffset;
    horizontalOffset-=anchorLeft;
    horizontalOffset+=marginsLeft - backgroundLeft;
  }
  if (windowWidth < widthSpec + horizontalOffset + anchorLeft) {
    int diff=Math.abs(windowWidth - (widthSpec + horizontalOffset + anchorLeft));
    horizontalOffset-=diff;
  }
 else   if (0 > anchorLeft + horizontalOffset) {
    int diff=Math.abs(horizontalOffset + anchorLeft);
    horizontalOffset+=diff;
  }
  int maxHeight=getMaxAvailableHeight(mDropDownAnchorView,noInputMethod) + backgroundTop + backgroundBottom;
  int availableHeight=maxHeight;
  availableHeight-=marginsTop - backgroundTop;
  availableHeight-=marginsBottom - backgroundBottom;
  int limitHeight=Math.min(windowHeight,availableHeight);
  final int heightSpec;
  if (mPopup.isShowing()) {
    if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
      heightSpec=limitHeight;
    }
 else     if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
      heightSpec=Math.min(height,limitHeight);
    }
 else {
      heightSpec=Math.min(mDropDownHeight,limitHeight);
    }
  }
 else {
    if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
      heightSpec=limitHeight;
    }
 else     if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
      heightSpec=Math.min(height,limitHeight);
    }
 else {
      heightSpec=Math.min(mDropDownHeight,limitHeight);
    }
  }
  final int screenBottom=windowBottom - (marginsBottom - backgroundBottom) - boundsBottom;
  final int screenTop=windowTop + (marginsTop - backgroundTop) + boundsTop;
{
    final int popupTop=anchorBottom + verticalOffset;
    final int popupBottom=popupTop + heightSpec;
    final int popupHeight=popupBottom - popupTop;
    if (popupBottom > screenBottom) {
      verticalOffset-=(popupBottom - screenBottom);
    }
 else     if (popupTop < screenTop) {
      verticalOffset+=(screenTop - popupTop);
    }
  }
{
    final int popupTop=anchorBottom + verticalOffset;
    final int popupBottom=popupTop + heightSpec;
    final int popupHeight=popupBottom - popupTop;
    if (windowBottom < popupBottom) {
      int diff=Math.abs(windowBottom - popupBottom);
      verticalOffset-=diff;
    }
 else     if (windowTop > popupTop) {
      int diff=Math.abs(windowTop - popupTop);
      verticalOffset+=diff;
    }
  }
  if (mPopup.isShowing()) {
    mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
    mPopup.update(getAnchorView(),horizontalOffset,verticalOffset,(widthSpec < 0) ? -1 : widthSpec,(heightSpec < 0) ? -1 : heightSpec);
  }
 else {
    mPopup.setWidth(widthSpec);
    mPopup.setHeight(heightSpec);
    setPopupClipToScreenEnabled(true);
    mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible);
    mPopup.setTouchInterceptor(mTouchInterceptor);
    PopupWindowCompat.showAsDropDown(mPopup,getAnchorView(),horizontalOffset,verticalOffset,Gravity.NO_GRAVITY);
    mDropDownList.setSelection(ListView.INVALID_POSITION);
    if (DEBUG)     Log.e(TAG,"isAboveAnchor=" + mPopup.isAboveAnchor());
    if (!mModal || mDropDownList.isInTouchMode()) {
      clearListSelection();
    }
    if (!mModal) {
      mHandler.post(mHideSelector);
    }
  }
}

public void show ( ) { final int height = buildDropDown ( ) ; final int widthSpec = getListWidthSpec ( ) ; boolean noInputMethod = isInputMethodNotNeeded ( ) ; PopupWindowCompat . setWindowLayoutType ( mPopup , mDropDownWindowLayoutType ) ; final int marginsLeft = mMargins . left ; final int marginsTop = mMargins . top ; final int marginsBottom = mMargins . bottom ; final int marginsRight = mMargins . right ; getBackgroundPadding ( mTempRect ) ; final int backgroundLeft = mTempRect . left ; final int backgroundTop = mTempRect . top ; final int backgroundBottom = mTempRect . bottom ; final int backgroundRight = mTempRect . right ; int verticalOffset = mDropDownVerticalOffset ; int horizontalOffset = mDropDownHorizontalOffset ; final int anchorWidth = mDropDownAnchorView . getWidth ( ) ; final int anchorHeight = mDropDownAnchorView . getHeight ( ) ; getLocationInWindow ( mDropDownAnchorView , mTempLocation ) ; final int anchorLeft = mTempLocation [ 0 ] ; final int anchorRight = anchorLeft + anchorWidth ; final int anchorTop = mTempLocation [ 1 ] ; final int anchorBottom = anchorTop + anchorHeight ; final boolean rightAligned = GravityCompat . getAbsoluteGravity ( getDropDownGravity ( ) & GravityCompat . RELATIVE_HORIZONTAL_GRAVITY_MASK , mLayoutDirection ) == Gravity . RIGHT ; if ( rightAligned ) { horizontalOffset += anchorWidth - widthSpec - ( marginsRight - backgroundRight ) ; } else { horizontalOffset += ( marginsLeft - backgroundLeft ) ; } final int bottomDecorations = getWindowFrame ( mDropDownAnchorView , noInputMethod , mTempRect ) ; final int windowLeft = mTempRect . left ; final int windowRight = mTempRect . right ; final int windowTop = mTempRect . top ; final int windowBottom = mTempRect . bottom ; final int windowWidth = windowRight - windowLeft ; final int windowHeight = windowBottom - windowTop ; getBoundsInWindow ( mTempRect ) ; final int boundsTop = mTempRect . top ; final int boundsRight = mTempRect . right ; final int boundsLeft = mTempRect . left ; final int boundsBottom = mTempRect . bottom ; final int screenRight = windowRight - ( marginsRight - backgroundRight ) - boundsRight ; final int screenLeft = windowLeft + ( marginsLeft - backgroundLeft ) + boundsLeft ; final int screenWidth = screenRight - screenLeft ; if ( ! rightAligned && windowWidth < anchorLeft + horizontalOffset + widthSpec ) { horizontalOffset = mDropDownHorizontalOffset < 0 ? 0 : mDropDownHorizontalOffset ; horizontalOffset -= widthSpec - ( windowWidth - anchorLeft ) ; horizontalOffset -= marginsRight - backgroundRight ; } else if ( rightAligned && 0 > anchorLeft + horizontalOffset ) { horizontalOffset = mDropDownHorizontalOffset > 0 ? 0 : mDropDownHorizontalOffset ; horizontalOffset -= anchorLeft ; horizontalOffset += marginsLeft - backgroundLeft ; } if ( windowWidth < widthSpec + horizontalOffset + anchorLeft ) { int diff = Math . abs ( windowWidth - ( widthSpec + horizontalOffset + anchorLeft ) ) ; horizontalOffset -= diff ; } else if ( 0 > anchorLeft + horizontalOffset ) { int diff = Math . abs ( horizontalOffset + anchorLeft ) ; horizontalOffset += diff ; } int maxHeight = getMaxAvailableHeight ( mDropDownAnchorView , noInputMethod ) + backgroundTop + backgroundBottom ; int availableHeight = maxHeight ; availableHeight -= marginsTop - backgroundTop ; availableHeight -= marginsBottom - backgroundBottom ; int limitHeight = Math . min ( windowHeight , availableHeight ) ; final int heightSpec ; if ( mPopup . isShowing ( ) ) { if ( mDropDownHeight == ViewGroup . LayoutParams . MATCH_PARENT ) { heightSpec = limitHeight ; } else if ( mDropDownHeight == ViewGroup . LayoutParams . WRAP_CONTENT ) { heightSpec = Math . min ( height , limitHeight ) ; } else { heightSpec = Math . min ( mDropDownHeight , limitHeight ) ; } } else { if ( mDropDownHeight == ViewGroup . LayoutParams . MATCH_PARENT ) { heightSpec = limitHeight ; } else if ( mDropDownHeight == ViewGroup . LayoutParams . WRAP_CONTENT ) { heightSpec = Math . min ( height , limitHeight ) ; } else { heightSpec = Math . min ( mDropDownHeight , limitHeight ) ; } } final int screenBottom = windowBottom - ( marginsBottom - backgroundBottom ) - boundsBottom ; final int screenTop = windowTop + ( marginsTop - backgroundTop ) + boundsTop ; { final int popupTop = anchorBottom + verticalOffset ; final int popupBottom = popupTop + heightSpec ; final int popupHeight = popupBottom - popupTop ; if ( popupBottom > screenBottom ) { verticalOffset -= ( popupBottom - screenBottom ) ; } else if ( popupTop < screenTop ) { verticalOffset += ( screenTop - popupTop ) ; } } { final int popupTop = anchorBottom + verticalOffset ; final int popupBottom = popupTop + heightSpec ; final int popupHeight = popupBottom - popupTop ; if ( windowBottom < popupBottom ) { int diff = Math . abs ( windowBottom - popupBottom ) ; verticalOffset -= diff ; } else if ( windowTop > popupTop ) { int diff = Math . abs ( windowTop - popupTop ) ; verticalOffset += diff ; } } if ( mPopup . isShowing ( ) ) { mPopup . setOutsideTouchable ( ! mForceIgnoreOutsideTouch && ! mDropDownAlwaysVisible ) ; mPopup . update ( getAnchorView ( ) , horizontalOffset , verticalOffset , ( widthSpec < 0 ) ? - 1 : widthSpec , ( heightSpec < 0 ) ? - 1 : heightSpec ) ; } else { mPopup . setWidth ( widthSpec ) ; mPopup . setHeight ( heightSpec ) ; setPopupClipToScreenEnabled ( true ) ; mPopup . setOutsideTouchable ( ! mForceIgnoreOutsideTouch && ! mDropDownAlwaysVisible ) ; mPopup . setTouchInterceptor ( mTouchInterceptor ) ; PopupWindowCompat . showAsDropDown ( mPopup , getAnchorView ( ) , horizontalOffset , verticalOffset , Gravity . NO_GRAVITY ) ; mDropDownList . setSelection ( ListView . INVALID_POSITION ) ; if ( DEBUG ) Log . e ( TAG , "isAboveAnchor=" + mPopup . isAboveAnchor ( ) ) ; if ( ! mModal || mDropDownList . isInTouchMode ( ) ) { clearListSelection ( ) ; } if ( ! mModal ) { mHandler . post ( mHideSelector ) ; } } }
show the popup list . if the list is already showing , this method will recalculate the popup ' s size and position .
