public void fillMarginLayoutParams(View view, ViewGroup.MarginLayoutParams params,
                                           int widthHint, int heightHint) {
            fillLayoutParams(params, widthHint, heightHint);

            // Preserve the original margins, so we can restore them after the measure step.
            mPreservedParams.leftMargin = params.leftMargin;
            mPreservedParams.topMargin = params.topMargin;
            mPreservedParams.rightMargin = params.rightMargin;
            mPreservedParams.bottomMargin = params.bottomMargin;
            MarginLayoutParamsCompat.setMarginStart(mPreservedParams,
                    MarginLayoutParamsCompat.getMarginStart(params));
            MarginLayoutParamsCompat.setMarginEnd(mPreservedParams,
                    MarginLayoutParamsCompat.getMarginEnd(params));
            int screenWidth = ScreenUtil.getScreenWidth(view.getContext());

            if (leftMarginPercentX >= 0) {
                params.leftMargin = Math.round(widthHint * leftMarginPercentX);
            }
            else if (leftMarginPercentY >= 0) {
                params.leftMargin = Math.round(heightHint * leftMarginPercentY);
            }
            else if (leftMarginPercentScreenX >= 0) {
                params.leftMargin = Math.round(screenWidth * leftMarginPercentScreenX);
            }


            if (topMarginPercentX >= 0) {
                params.topMargin = Math.round(widthHint * topMarginPercentX);
            }
            else if (topMarginPercentY >= 0) {
                params.topMargin = Math.round(heightHint * topMarginPercentY);
            }
            else if (topMarginPercentScreenX >= 0) {
                params.topMargin = Math.round(screenWidth * topMarginPercentScreenX);
            }


            if (rightMarginPercentX >= 0) {
                params.rightMargin = Math.round(widthHint * rightMarginPercentX);
            }
            else if (rightMarginPercentY >= 0) {
                params.rightMargin = Math.round(heightHint * rightMarginPercentY);
            }
            else if (rightMarginPercentScreenX >= 0) {
                params.rightMargin = Math.round(screenWidth * rightMarginPercentScreenX);
            }


            if (bottomMarginPercentX >= 0) {
                params.bottomMargin = Math.round(widthHint * bottomMarginPercentX);
            }
            else if(bottomMarginPercentY >= 0){
                params.bottomMargin = Math.round(heightHint * bottomMarginPercentY);
            }
            else if(bottomMarginPercentScreenX >= 0){
                params.bottomMargin = Math.round(screenWidth * bottomMarginPercentScreenX);
            }


            boolean shouldResolveLayoutDirection = false;
            if (startMarginPercent >= 0) {
                MarginLayoutParamsCompat.setMarginStart(params,
                        Math.round(widthHint * startMarginPercent));
                shouldResolveLayoutDirection = true;
            }
            if (endMarginPercent >= 0) {
                MarginLayoutParamsCompat.setMarginEnd(params,
                        Math.round(widthHint * endMarginPercent));
                shouldResolveLayoutDirection = true;
            }
            if (shouldResolveLayoutDirection && (view != null)) {
                // Force the resolve pass so that start / end margins are propagated to the
                // matching left / right fields
                MarginLayoutParamsCompat.resolveLayoutDirection(params,
                        ViewCompat.getLayoutDirection(view));
            }
            if (DEBUG) {
                Log.d(TAG, "after fillMarginLayoutParams: (" + params.width + ", " + params.height
                        + ")");
            }
        }
Fills the margin fields of the passed {@link ViewGroup.MarginLayoutParams} object based
on currently set percentage values and the current layout direction of the passed
{@link View}.
common/src/main/java/com/sxjs/common/widget/percentlayout/PercentLayoutHelper.java