Code example for ImageView

Methods: getLayoutParams

        int arrowOffset = (anchorWidth - mArrowWidth)/2 + mAnchor.getPaddingLeft();
        // The horizontal offset of the popup window, relative to the left side of the anchor view. 
        int offset = 0;
        RelativeLayout.LayoutParams arrowLayoutParams = (RelativeLayout.LayoutParams) mArrow.getLayoutParams();
        if (HardwareUtils.isTablet()) { 
            // On tablets, the popup has a fixed width, so we use a horizontal offset to position it. 
            // The arrow's left margin is set by the arrow_popup.xml layout file. 
            // This assumes that anchor is not too close to the right side of the screen. 
            offset = arrowOffset - arrowLayoutParams.leftMargin;
        } else { 
            // On phones, the popup takes up the width of the screen, so we set the arrow's left 
            // margin to make it line up with the anchor. 
            int leftMargin = anchorLocation[0] + arrowOffset;
            arrowLayoutParams.setMargins(leftMargin, 0, 0, 0);
        showAsDropDown(mAnchor, offset, -mYOffset);