Code example for FrameLayout

Methods: getPaddingBottomgetPaddingLeftgetPaddingRightgetPaddingTopmeasurelayout

0
        int frameHeight = getHeight();
 
        FrameLayout f = mFrame;
 
        int horizontalPadding = Math.max(
                f.getPaddingLeft() + f.getPaddingRight(),
                (int) (MIN_HORIZONTAL_MARGIN * mMetrics.density));
        int verticalPadding = f.getPaddingBottom() + f.getPaddingTop();
 
        // Ignore the vertical paddings, so that we won't draw the frame on the 
        // top and bottom sides 
        int previewHeight = frameHeight;
        int previewWidth = frameWidth - horizontalPadding;
 
        // resize frame and preview for aspect ratio 
        if(mAspectRatio >= 0.0){
	        if (previewWidth > previewHeight * mAspectRatio) {
	            previewWidth = (int) (previewHeight * mAspectRatio + .5);
	        } else { 
	            previewHeight = (int) (previewWidth / mAspectRatio + .5);
	        } 
        } 
 
        frameWidth = previewWidth + horizontalPadding;
        frameHeight = previewHeight + verticalPadding;
 
        int hSpace = ((r - l) - frameWidth) / 2;
        int vSpace = ((b - t) - frameHeight) / 2;
        mFrame.measure(
                MeasureSpec.makeMeasureSpec(frameWidth, MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(frameHeight, MeasureSpec.EXACTLY));
        mFrame.layout(l + hSpace, t + vSpace, r - hSpace, b - vSpace);
        if (mSizeListener != null) {
            mSizeListener.onSizeChanged();
        } 
    } 
} 
Contextual code suggestions in your IDE  Get Codota for Java