Java Code Examples for android.support.v4.view.MarginLayoutParamsCompat#getMarginEnd()

The following examples show how to use android.support.v4.view.MarginLayoutParamsCompat#getMarginEnd() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From imsdk-android with MIT License 5 votes vote down vote up
static int getMarginEnd(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 2
Source File: Utils.java    From imsdk-android with MIT License 5 votes vote down vote up
static int getMarginHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 3
Source File: Utils.java    From RecyclerPager with Apache License 2.0 5 votes vote down vote up
static int getMarginEnd(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 4
Source File: Utils.java    From RecyclerPager with Apache License 2.0 5 votes vote down vote up
static int getMarginHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 5
Source File: Utils.java    From KUtils with Apache License 2.0 5 votes vote down vote up
static int getMarginEnd(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 6
Source File: Utils.java    From KUtils with Apache License 2.0 5 votes vote down vote up
static int getMarginHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 7
Source File: Utils.java    From SmartChart with Apache License 2.0 5 votes vote down vote up
static int getMarginEnd(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 8
Source File: Utils.java    From SmartChart with Apache License 2.0 5 votes vote down vote up
static int getMarginHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 9
Source File: Utils.java    From KUtils-master with Apache License 2.0 5 votes vote down vote up
static int getMarginEnd(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 10
Source File: Utils.java    From KUtils-master with Apache License 2.0 5 votes vote down vote up
static int getMarginHorizontally(View v) {
  if (v == null) {
    return 0;
  }
  ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
  return MarginLayoutParamsCompat.getMarginStart(lp) + MarginLayoutParamsCompat.getMarginEnd(lp);
}
 
Example 11
Source File: FlexboxHelper.java    From Collection-Android with MIT License 4 votes vote down vote up
/**
 * Place a single View when the layout direction is vertical
 * ({@link FlexContainer#getFlexDirection()} is either {@link FlexDirection#COLUMN} or
 * {@link FlexDirection#COLUMN_REVERSE}).
 *
 * @param view     the View to be placed
 * @param flexLine the {@link FlexLine} where the View belongs to
 * @param isRtl    {@code true} if the layout direction is right to left, {@code false}
 *                 otherwise
 * @param left     the left position of the flex line where the View belongs to. The actual
 *                 View's left position is shifted depending on the isLayoutRtl and alignItems
 *                 attributes
 * @param top      the top position of the View, which the View's margin is already taken
 *                 into account
 * @param right    the right position of the flex line where the View belongs to. The actual
 *                 View's right position is shifted depending on the isLayoutRtl and alignItems
 *                 attributes
 * @param bottom   the bottom position of the View, which the View's margin is already taken
 *                 into account
 * @see FlexContainer#getAlignItems()
 * @see FlexContainer#setAlignItems(int)
 * @see FlexItem#getAlignSelf()
 */
void layoutSingleChildVertical(View view, FlexLine flexLine, boolean isRtl,
                               int left, int top, int right, int bottom) {
    FlexItem flexItem = (FlexItem) view.getLayoutParams();
    int alignItems = mFlexContainer.getAlignItems();
    if (flexItem.getAlignSelf() != AlignSelf.AUTO) {
        // Expecting the values for alignItems and mAlignSelf match except for ALIGN_SELF_AUTO.
        // Assigning the mAlignSelf value as alignItems should work.
        alignItems = flexItem.getAlignSelf();
    }
    int crossSize = flexLine.mCrossSize;
    switch (alignItems) {
        case AlignItems.FLEX_START: // Intentional fall through
        case AlignItems.STRETCH: // Intentional fall through
        case AlignItems.BASELINE:
            if (!isRtl) {
                view.layout(left + flexItem.getMarginLeft(), top,
                        right + flexItem.getMarginLeft(), bottom);
            } else {
                view.layout(left - flexItem.getMarginRight(), top,
                        right - flexItem.getMarginRight(), bottom);
            }
            break;
        case AlignItems.FLEX_END:
            if (!isRtl) {
                view.layout(
                        left + crossSize - view.getMeasuredWidth() - flexItem.getMarginRight(),
                        top,
                        right + crossSize - view.getMeasuredWidth() - flexItem.getMarginRight(),
                        bottom);
            } else {
                // If the flexWrap == WRAP_REVERSE, the direction of the
                // flexEnd is flipped (from left to right).
                view.layout(
                        left - crossSize + view.getMeasuredWidth() + flexItem.getMarginLeft(),
                        top,
                        right - crossSize + view.getMeasuredWidth() + flexItem.getMarginLeft(),
                        bottom);
            }
            break;
        case AlignItems.CENTER:
            ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams)
                    view.getLayoutParams();
            int leftFromCrossAxis = (crossSize - view.getMeasuredWidth()
                    + MarginLayoutParamsCompat.getMarginStart(lp)
                    - MarginLayoutParamsCompat.getMarginEnd(lp)) / 2;
            if (!isRtl) {
                view.layout(left + leftFromCrossAxis, top, right + leftFromCrossAxis, bottom);
            } else {
                view.layout(left - leftFromCrossAxis, top, right - leftFromCrossAxis, bottom);
            }
            break;
    }
}
 
Example 12
Source File: FlexboxLayout.java    From JD-Test with Apache License 2.0 4 votes vote down vote up
/**
 * Place a single View when the layout direction is vertical ({@link #mFlexDirection} is
 * either {@link #FLEX_DIRECTION_COLUMN} or {@link #FLEX_DIRECTION_COLUMN_REVERSE}).
 *
 * @param view       the View to be placed
 * @param flexLine   the {@link FlexLine} where the View belongs to
 * @param isRtl      {@code true} if the layout direction is right to left, {@code false}
 *                   otherwise
 * @param alignItems the align items attribute of this FlexboxLayout
 * @param left       the left position of the flex line where the View belongs to. The actual
 *                   View's left position is shifted depending on the isRtl and alignItems
 *                   attributes
 * @param top        the top position of the View, which the View's margin is already taken
 *                   into account
 * @param right      the right position of the flex line where the View belongs to. The actual
 *                   View's right position is shifted depending on the isRtl and alignItems
 *                   attributes
 * @param bottom     the bottom position of the View, which the View's margin is already taken
 *                   into account
 * @see #getAlignItems()
 * @see #setAlignItems(int)
 * @see LayoutParams#alignSelf
 */
private void layoutSingleChildVertical(View view, FlexLine flexLine, boolean isRtl,
        int alignItems, int left, int top, int right, int bottom) {
    LayoutParams lp = (LayoutParams) view.getLayoutParams();
    if (lp.alignSelf != LayoutParams.ALIGN_SELF_AUTO) {
        // Expecting the values for alignItems and alignSelf match except for ALIGN_SELF_AUTO.
        // Assigning the alignSelf value as alignItems should work.
        alignItems = lp.alignSelf;
    }
    int crossSize = flexLine.mCrossSize;
    switch (alignItems) {
        case ALIGN_ITEMS_FLEX_START: // Intentional fall through
        case ALIGN_ITEMS_STRETCH: // Intentional fall through
        case ALIGN_ITEMS_BASELINE:
            if (!isRtl) {
                view.layout(left + lp.leftMargin, top, right + lp.leftMargin, bottom);
            } else {
                view.layout(left - lp.rightMargin, top, right - lp.rightMargin, bottom);
            }
            break;
        case ALIGN_ITEMS_FLEX_END:
            if (!isRtl) {
                view.layout(left + crossSize - view.getMeasuredWidth() - lp.rightMargin,
                        top, right + crossSize - view.getMeasuredWidth() - lp.rightMargin,
                        bottom);
            } else {
                // If the flexWrap == FLEX_WRAP_WRAP_REVERSE, the direction of the
                // flexEnd is flipped (from left to right).
                view.layout(left - crossSize + view.getMeasuredWidth() + lp.leftMargin, top,
                        right - crossSize + view.getMeasuredWidth() + lp.leftMargin,
                        bottom);
            }
            break;
        case ALIGN_ITEMS_CENTER:
            int leftFromCrossAxis = (crossSize - view.getMeasuredWidth()
                    + MarginLayoutParamsCompat.getMarginStart(lp)
                    - MarginLayoutParamsCompat.getMarginEnd(lp)) / 2;
            if (!isRtl) {
                view.layout(left + leftFromCrossAxis, top, right + leftFromCrossAxis, bottom);
            } else {
                view.layout(left - leftFromCrossAxis, top, right - leftFromCrossAxis, bottom);
            }
            break;
    }
}