mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(layout-params): respect width/height properties with percent values (#127)
This commit is contained in:
committed by
GitHub
parent
d94175b5a7
commit
3253cd4a22
@@ -118,7 +118,7 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
|
|||||||
int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||||
|
|
||||||
// If we have explicit height and gravity is FILL we need to be centered otherwise our explicit height won't be taken into account.
|
// If we have explicit height and gravity is FILL we need to be centered otherwise our explicit height won't be taken into account.
|
||||||
if (lp.height >= 0 && verticalGravity == Gravity.FILL_VERTICAL) {
|
if ((lp.height >= 0 || lp.heightPercent >= 0) && verticalGravity == Gravity.FILL_VERTICAL) {
|
||||||
verticalGravity = Gravity.CENTER_VERTICAL;
|
verticalGravity = Gravity.CENTER_VERTICAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ public class CommonLayoutParams extends FrameLayout.LayoutParams {
|
|||||||
int horizontalGravity = Gravity.getAbsoluteGravity(gravity, child.getLayoutDirection()) & Gravity.HORIZONTAL_GRAVITY_MASK;
|
int horizontalGravity = Gravity.getAbsoluteGravity(gravity, child.getLayoutDirection()) & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||||
|
|
||||||
// If we have explicit width and gravity is FILL we need to be centered otherwise our explicit width won't be taken into account.
|
// If we have explicit width and gravity is FILL we need to be centered otherwise our explicit width won't be taken into account.
|
||||||
if (lp.width >= 0 && horizontalGravity == Gravity.FILL_HORIZONTAL) {
|
if ((lp.width >= 0 || lp.widthPercent >= 0) && horizontalGravity == Gravity.FILL_HORIZONTAL) {
|
||||||
horizontalGravity = Gravity.CENTER_HORIZONTAL;
|
horizontalGravity = Gravity.CENTER_HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user