提交 fb2b6339 编写于 作者: T Takeshi Hagikura 提交者: GitHub

Fix the issue that horizontal margin is ignored on devices with API (#354)

level < 17.
Because the FlexboxHelper expected
ViewGroup.MarginLayoutParams#getMarginStart (getMarginEnd) methods when
calculating the wrap condition.

No devices are available on API level < 17  on Firebase Test Lab. So
manually ran the tests on an emulator with API level 16.
上级 14f2a42d
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:text="1" android:text="1"
app:layout_flexBasisPercent="50%" app:layout_flexBasisPercent="50%"
app:layout_flexGrow="1" app:layout_flexGrow="1"
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="150dp" android:layout_height="150dp"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:text="1" android:text="1"
app:layout_flexShrink="1" /> app:layout_flexShrink="1" />
......
...@@ -738,6 +738,11 @@ class FlexboxHelper { ...@@ -738,6 +738,11 @@ class FlexboxHelper {
/** /**
* Returns the flexItem's start margin in the main axis. Either start or top. * Returns the flexItem's start margin in the main axis. Either start or top.
* For the backward compatibility for API level < 17, the horizontal margin is returned using
* {@link FlexItem#getMarginLeft} (ViewGroup.MarginLayoutParams#getMarginStart isn't available
* in API level < 17). Thus this method needs to be used with {@link #getFlexItemMarginEndMain}
* not to misuse the margin in RTL.
*
* *
* @param flexItem the flexItem * @param flexItem the flexItem
* @param isMainHorizontal is the main axis horizontal * @param isMainHorizontal is the main axis horizontal
...@@ -745,7 +750,7 @@ class FlexboxHelper { ...@@ -745,7 +750,7 @@ class FlexboxHelper {
*/ */
private int getFlexItemMarginStartMain(FlexItem flexItem, boolean isMainHorizontal) { private int getFlexItemMarginStartMain(FlexItem flexItem, boolean isMainHorizontal) {
if (isMainHorizontal) { if (isMainHorizontal) {
return flexItem.getMarginStart(); return flexItem.getMarginLeft();
} }
return flexItem.getMarginTop(); return flexItem.getMarginTop();
...@@ -753,6 +758,10 @@ class FlexboxHelper { ...@@ -753,6 +758,10 @@ class FlexboxHelper {
/** /**
* Returns the flexItem's end margin in the main axis. Either end or bottom. * Returns the flexItem's end margin in the main axis. Either end or bottom.
* For the backward compatibility for API level < 17, the horizontal margin is returned using
* {@link FlexItem#getMarginRight} (ViewGroup.MarginLayoutParams#getMarginEnd isn't available
* in API level < 17). Thus this method needs to be used with
* {@link #getFlexItemMarginStartMain} not to misuse the margin in RTL.
* *
* @param flexItem the flexItem * @param flexItem the flexItem
* @param isMainHorizontal is the main axis horizontal * @param isMainHorizontal is the main axis horizontal
...@@ -760,7 +769,7 @@ class FlexboxHelper { ...@@ -760,7 +769,7 @@ class FlexboxHelper {
*/ */
private int getFlexItemMarginEndMain(FlexItem flexItem, boolean isMainHorizontal) { private int getFlexItemMarginEndMain(FlexItem flexItem, boolean isMainHorizontal) {
if (isMainHorizontal) { if (isMainHorizontal) {
return flexItem.getMarginEnd(); return flexItem.getMarginRight();
} }
return flexItem.getMarginBottom(); return flexItem.getMarginBottom();
...@@ -768,6 +777,10 @@ class FlexboxHelper { ...@@ -768,6 +777,10 @@ class FlexboxHelper {
/** /**
* Returns the flexItem's start margin in the cross axis. Either start or top. * Returns the flexItem's start margin in the cross axis. Either start or top.
* For the backward compatibility for API level < 17, the horizontal margin is returned using
* {@link FlexItem#getMarginLeft} (ViewGroup.MarginLayoutParams#getMarginStart isn't available
* in API level < 17). Thus this method needs to be used with
* {@link #getFlexItemMarginEndCross} to not to misuse the margin in RTL.
* *
* @param flexItem the flexItem * @param flexItem the flexItem
* @param isMainHorizontal is the main axis horizontal * @param isMainHorizontal is the main axis horizontal
...@@ -778,11 +791,15 @@ class FlexboxHelper { ...@@ -778,11 +791,15 @@ class FlexboxHelper {
return flexItem.getMarginTop(); return flexItem.getMarginTop();
} }
return flexItem.getMarginStart(); return flexItem.getMarginLeft();
} }
/** /**
* Returns the flexItem's end margin in the cross axis. Either end or bottom. * Returns the flexItem's end margin in the cross axis. Either end or bottom.
* For the backward compatibility for API level < 17, the horizontal margin is returned using
* {@link FlexItem#getMarginRight} (ViewGroup.MarginLayoutParams#getMarginEnd isn't available
* in API level < 17). Thus this method needs to be used with
* {@link #getFlexItemMarginStartCross} to not to misuse the margin in RTL.
* *
* @param flexItem the flexItem * @param flexItem the flexItem
* @param isMainHorizontal is the main axis horizontal * @param isMainHorizontal is the main axis horizontal
...@@ -793,7 +810,7 @@ class FlexboxHelper { ...@@ -793,7 +810,7 @@ class FlexboxHelper {
return flexItem.getMarginBottom(); return flexItem.getMarginBottom();
} }
return flexItem.getMarginEnd(); return flexItem.getMarginRight();
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册