@@ -738,36 +738,49 @@ private int getFlexItemSizeCross(FlexItem flexItem, boolean isMainHorizontal) {
738738
739739 /**
740740 * Returns the flexItem's start margin in the main axis. Either start or top.
741+ * For the backward compatibility for API level < 17, the horizontal margin is returned using
742+ * {@link FlexItem#getMarginLeft} (ViewGroup.MarginLayoutParams#getMarginStart isn't available
743+ * in API level < 17). Thus this method needs to be used with {@link #getFlexItemMarginEndMain}
744+ * not to misuse the margin in RTL.
745+ *
741746 *
742747 * @param flexItem the flexItem
743748 * @param isMainHorizontal is the main axis horizontal
744749 * @return the flexItem's start margin in the main axis
745750 */
746751 private int getFlexItemMarginStartMain (FlexItem flexItem , boolean isMainHorizontal ) {
747752 if (isMainHorizontal ) {
748- return flexItem .getMarginStart ();
753+ return flexItem .getMarginLeft ();
749754 }
750755
751756 return flexItem .getMarginTop ();
752757 }
753758
754759 /**
755760 * Returns the flexItem's end margin in the main axis. Either end or bottom.
761+ * For the backward compatibility for API level < 17, the horizontal margin is returned using
762+ * {@link FlexItem#getMarginRight} (ViewGroup.MarginLayoutParams#getMarginEnd isn't available
763+ * in API level < 17). Thus this method needs to be used with
764+ * {@link #getFlexItemMarginStartMain} not to misuse the margin in RTL.
756765 *
757766 * @param flexItem the flexItem
758767 * @param isMainHorizontal is the main axis horizontal
759768 * @return the flexItem's end margin in the main axis
760769 */
761770 private int getFlexItemMarginEndMain (FlexItem flexItem , boolean isMainHorizontal ) {
762771 if (isMainHorizontal ) {
763- return flexItem .getMarginEnd ();
772+ return flexItem .getMarginRight ();
764773 }
765774
766775 return flexItem .getMarginBottom ();
767776 }
768777
769778 /**
770779 * Returns the flexItem's start margin in the cross axis. Either start or top.
780+ * For the backward compatibility for API level < 17, the horizontal margin is returned using
781+ * {@link FlexItem#getMarginLeft} (ViewGroup.MarginLayoutParams#getMarginStart isn't available
782+ * in API level < 17). Thus this method needs to be used with
783+ * {@link #getFlexItemMarginEndCross} to not to misuse the margin in RTL.
771784 *
772785 * @param flexItem the flexItem
773786 * @param isMainHorizontal is the main axis horizontal
@@ -778,11 +791,15 @@ private int getFlexItemMarginStartCross(FlexItem flexItem, boolean isMainHorizon
778791 return flexItem .getMarginTop ();
779792 }
780793
781- return flexItem .getMarginStart ();
794+ return flexItem .getMarginLeft ();
782795 }
783796
784797 /**
785798 * Returns the flexItem's end margin in the cross axis. Either end or bottom.
799+ * For the backward compatibility for API level < 17, the horizontal margin is returned using
800+ * {@link FlexItem#getMarginRight} (ViewGroup.MarginLayoutParams#getMarginEnd isn't available
801+ * in API level < 17). Thus this method needs to be used with
802+ * {@link #getFlexItemMarginStartCross} to not to misuse the margin in RTL.
786803 *
787804 * @param flexItem the flexItem
788805 * @param isMainHorizontal is the main axis horizontal
@@ -793,7 +810,7 @@ private int getFlexItemMarginEndCross(FlexItem flexItem, boolean isMainHorizonta
793810 return flexItem .getMarginBottom ();
794811 }
795812
796- return flexItem .getMarginEnd ();
813+ return flexItem .getMarginRight ();
797814 }
798815
799816 /**
0 commit comments