mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix(button-android): use setMinWidth to set TextView widgets min-width (#7804)
* fix: setMinimumWidth does not really set the minWidth for TextView widgets * chore: fix versions * refactor(android): default minWidth/Height values for button * reafctor: reset minWidth when view is in flexbox for backcompat * refactor: ensure back-compatible layout for btns * chore: cut 6.5.0 release (#8443) * release: cut 6.5.0 release * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com> Co-authored-by: vakrilov <alexander.vakrilov@telerik.com> Co-authored-by: Dimitar Topuzov <dtopuzov@gmail.com> Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com>
This commit is contained in:

committed by
GitHub

parent
1f04469fb3
commit
66cc8a477e
19
CHANGELOG.md
19
CHANGELOG.md
@ -1,3 +1,22 @@
|
|||||||
|
# [6.5.0](https://github.com/NativeScript/NativeScript/compare/6.4.2...6.5.0) (2020-03-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Fix issue for view not being removed from its parent ([#8432](https://github.com/NativeScript/NativeScript/issues/8432)) ([e081340](https://github.com/NativeScript/NativeScript/commit/e081340665605c54530587cc0cce9bc339585557))
|
||||||
|
* **d.ts:** Update iOS typings iOS 13.2 ([#8430](https://github.com/NativeScript/NativeScript/issues/8430)) ([18a9b1a](https://github.com/NativeScript/NativeScript/commit/18a9b1aea89ee9defee990ace7d2409327a47a28))
|
||||||
|
* **bottom-nav:** Android TabStripItems not aligned correctly when one of the image is smaller ([#8414](https://github.com/NativeScript/NativeScript/issues/8414))([9830be7](https://github.com/NativeScript/NativeScript/commit/9830be7230355638ace604145a3e3fad393c2a93))
|
||||||
|
* **tabs:** delay loadView when animation runs ([#8353](https://github.com/NativeScript/NativeScript/issues/8353)) ([e649a6c](https://github.com/NativeScript/NativeScript/commit/e649a6cfd618c86a1dc7fa84e3197dfb78c3bc74))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **tabs:** Tabs styling improvements ([#8366](https://github.com/NativeScript/NativeScript/pull/8366))([4589431](https://github.com/NativeScript/NativeScript/commit/458943111e909fcdad47d12e7ee4bcd9732f4e90))
|
||||||
|
* **tabs:** Added selectedItemColor and unSelectedItemColor to the TabStrip ([#8435](https://github.com/NativeScript/NativeScript/issues/8435))([243dc98](https://github.com/NativeScript/NativeScript/commit/243dc98005d43617872da5cfc010e76178aa7f97))
|
||||||
|
* **gestures:** add locationX and locationY to double tap event data ([#8338](https://github.com/NativeScript/NativeScript/pull/8338))([5ff78e2](https://github.com/NativeScript/NativeScript/commit/5ff78e2ad2612259bff36d3aaf5a0292309f5a78))
|
||||||
|
* **tabs:** Added iconClass property to TabStripItem ([#8439](https://github.com/NativeScript/NativeScript/issues/8439))([270988d](https://github.com/NativeScript/NativeScript/commit/270988d26e1eeab97b4e5781451388e3a0a347e3))
|
||||||
|
|
||||||
|
|
||||||
## [6.4.2](https://github.com/NativeScript/NativeScript/compare/6.4.1...6.4.2) (2020-02-27)
|
## [6.4.2](https://github.com/NativeScript/NativeScript/compare/6.4.1...6.4.2) (2020-02-27)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2896,6 +2896,8 @@ export abstract class ViewBase extends Observable {
|
|||||||
public _goToVisualState(state: string): void;
|
public _goToVisualState(state: string): void;
|
||||||
public id: string;
|
public id: string;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
|
public _ignoreFlexMinWidthHeightReset: boolean;
|
||||||
|
// (undocumented)
|
||||||
_inheritStyleScope(styleScope: any /* StyleScope */): void;
|
_inheritStyleScope(styleScope: any /* StyleScope */): void;
|
||||||
initNativeView(): void;
|
initNativeView(): void;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
|
@ -41,12 +41,14 @@
|
|||||||
"ios": "6.0.0",
|
"ios": "6.0.0",
|
||||||
"android": "6.0.0"
|
"android": "6.0.0"
|
||||||
},
|
},
|
||||||
"hooks": [{
|
"hooks": [
|
||||||
"name": "nativescript-core",
|
{
|
||||||
"type": "before-checkForChanges",
|
"name": "nativescript-core",
|
||||||
"script": "cli-hooks/before-checkForChanges.js",
|
"type": "before-checkForChanges",
|
||||||
"inject": true
|
"script": "cli-hooks/before-checkForChanges.js",
|
||||||
}]
|
"inject": true
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"snapshot": {
|
"snapshot": {
|
||||||
"android": {
|
"android": {
|
||||||
@ -58,4 +60,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
ButtonBase, PseudoClassHandler,
|
ButtonBase, PseudoClassHandler,
|
||||||
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty,
|
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty,
|
||||||
Length, zIndexProperty, textAlignmentProperty, TextAlignment
|
Length, zIndexProperty, textAlignmentProperty, TextAlignment, layout,
|
||||||
|
minWidthProperty, minHeightProperty
|
||||||
} from "./button-common";
|
} from "./button-common";
|
||||||
import { profile } from "../../profiling";
|
import { profile } from "../../profiling";
|
||||||
import { TouchGestureEventData, GestureTypes, TouchAction } from "../gestures";
|
import { TouchGestureEventData, GestureTypes, TouchAction } from "../gestures";
|
||||||
@ -111,6 +112,18 @@ export class Button extends ButtonBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[minWidthProperty.getDefault](): Length {
|
||||||
|
const dips = org.nativescript.widgets.ViewHelper.getMinWidth(this.nativeViewProtected);
|
||||||
|
|
||||||
|
return { value: dips, unit: "px" };
|
||||||
|
}
|
||||||
|
|
||||||
|
[minHeightProperty.getDefault](): Length {
|
||||||
|
const dips = org.nativescript.widgets.ViewHelper.getMinHeight(this.nativeViewProtected);
|
||||||
|
|
||||||
|
return { value: dips, unit: "px" };
|
||||||
|
}
|
||||||
|
|
||||||
[paddingTopProperty.getDefault](): Length {
|
[paddingTopProperty.getDefault](): Length {
|
||||||
return { value: this._defaultPaddingTop, unit: "px" };
|
return { value: this._defaultPaddingTop, unit: "px" };
|
||||||
}
|
}
|
||||||
@ -177,3 +190,5 @@ export class Button extends ButtonBase {
|
|||||||
return 4; // 4dp @dimen/button_pressed_z_material
|
return 4; // 4dp @dimen/button_pressed_z_material
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button.prototype._ignoreFlexMinWidthHeightReset = true;
|
||||||
|
@ -432,10 +432,17 @@ export abstract class ViewBase extends Observable {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
public recycleNativeView: "always" | "never" | "auto";
|
public recycleNativeView: "always" | "never" | "auto";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
public _isPaddingRelative: boolean;
|
public _isPaddingRelative: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
public _ignoreFlexMinWidthHeightReset: boolean;
|
||||||
|
|
||||||
public _styleScope: any;
|
public _styleScope: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,6 +227,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
|||||||
_oldTop: number;
|
_oldTop: number;
|
||||||
_oldRight: number;
|
_oldRight: number;
|
||||||
_oldBottom: number;
|
_oldBottom: number;
|
||||||
|
_ignoreFlexMinWidthHeightReset: boolean;
|
||||||
|
|
||||||
public effectiveMinWidth: number;
|
public effectiveMinWidth: number;
|
||||||
public effectiveMinHeight: number;
|
public effectiveMinHeight: number;
|
||||||
|
@ -389,7 +389,7 @@ export class View extends ViewCommon {
|
|||||||
this.nativeViewProtected.setClickable(this._isClickable);
|
this.nativeViewProtected.setClickable(this._isClickable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._manager = null;
|
this._manager = null;
|
||||||
this._rootManager = null;
|
this._rootManager = null;
|
||||||
super.onUnloaded();
|
super.onUnloaded();
|
||||||
@ -982,17 +982,17 @@ export class View extends ViewCommon {
|
|||||||
|
|
||||||
[minWidthProperty.setNative](value: Length) {
|
[minWidthProperty.setNative](value: Length) {
|
||||||
if (this.parent instanceof CustomLayoutView && this.parent.nativeViewProtected) {
|
if (this.parent instanceof CustomLayoutView && this.parent.nativeViewProtected) {
|
||||||
this.parent._setChildMinWidthNative(this);
|
this.parent._setChildMinWidthNative(this, value);
|
||||||
} else {
|
} else {
|
||||||
this._setMinWidthNative(this.minWidth);
|
this._setMinWidthNative(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[minHeightProperty.setNative](value: Length) {
|
[minHeightProperty.setNative](value: Length) {
|
||||||
if (this.parent instanceof CustomLayoutView && this.parent.nativeViewProtected) {
|
if (this.parent instanceof CustomLayoutView && this.parent.nativeViewProtected) {
|
||||||
this.parent._setChildMinHeightNative(this);
|
this.parent._setChildMinHeightNative(this, value);
|
||||||
} else {
|
} else {
|
||||||
this._setMinHeightNative(this.minHeight);
|
this._setMinHeightNative(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1050,16 +1050,15 @@ export class CustomLayoutView extends ContainerView implements CustomLayoutViewD
|
|||||||
}
|
}
|
||||||
|
|
||||||
public _updateNativeLayoutParams(child: View): void {
|
public _updateNativeLayoutParams(child: View): void {
|
||||||
this._setChildMinWidthNative(child);
|
// noop
|
||||||
this._setChildMinHeightNative(child);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public _setChildMinWidthNative(child: View): void {
|
public _setChildMinWidthNative(child: View, value: Length): void {
|
||||||
child._setMinWidthNative(child.minWidth);
|
child._setMinWidthNative(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _setChildMinHeightNative(child: View): void {
|
public _setChildMinHeightNative(child: View, value: Length): void {
|
||||||
child._setMinHeightNative(child.minHeight);
|
child._setMinHeightNative(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _removeViewFromNativeVisualTree(child: ViewCommon): void {
|
public _removeViewFromNativeVisualTree(child: ViewCommon): void {
|
||||||
|
4
nativescript-core/ui/core/view/view.d.ts
vendored
4
nativescript-core/ui/core/view/view.d.ts
vendored
@ -796,11 +796,11 @@ export class CustomLayoutView extends ContainerView {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_setChildMinWidthNative(child: View): void;
|
_setChildMinWidthNative(child: View, value: Length): void;
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_setChildMinHeightNative(child: View): void;
|
_setChildMinHeightNative(child: View, value: Length): void;
|
||||||
//@endprivate
|
//@endprivate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ import {
|
|||||||
flexShrinkProperty, FlexShrink,
|
flexShrinkProperty, FlexShrink,
|
||||||
flexWrapBeforeProperty, FlexWrapBefore,
|
flexWrapBeforeProperty, FlexWrapBefore,
|
||||||
alignSelfProperty, AlignSelf,
|
alignSelfProperty, AlignSelf,
|
||||||
flexDirectionProperty, flexWrapProperty, justifyContentProperty, alignItemsProperty, alignContentProperty
|
flexDirectionProperty, flexWrapProperty, justifyContentProperty, alignItemsProperty, alignContentProperty,
|
||||||
|
minWidthProperty, minHeightProperty,
|
||||||
|
CssProperty
|
||||||
} from "./flexbox-layout-common";
|
} from "./flexbox-layout-common";
|
||||||
|
|
||||||
export * from "./flexbox-layout-common";
|
export * from "./flexbox-layout-common";
|
||||||
@ -137,6 +139,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
public _updateNativeLayoutParams(child: View): void {
|
public _updateNativeLayoutParams(child: View): void {
|
||||||
super._updateNativeLayoutParams(child);
|
super._updateNativeLayoutParams(child);
|
||||||
|
|
||||||
|
// NOTE: If minWidth/Height is not set, the next code will clear the default native values for minWidth/Height.
|
||||||
|
// Flex box will not respect the button default min width. Keeping this behavior for back-compatibility.
|
||||||
|
this._setChildMinWidthNative(child, child.minWidth);
|
||||||
|
this._setChildMinHeightNative(child, child.minHeight);
|
||||||
|
|
||||||
const lp = <org.nativescript.widgets.FlexboxLayout.LayoutParams>child.nativeViewProtected.getLayoutParams();
|
const lp = <org.nativescript.widgets.FlexboxLayout.LayoutParams>child.nativeViewProtected.getLayoutParams();
|
||||||
const style = child.style;
|
const style = child.style;
|
||||||
lp.order = style.order;
|
lp.order = style.order;
|
||||||
@ -147,22 +154,30 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
child.nativeViewProtected.setLayoutParams(lp);
|
child.nativeViewProtected.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public _setChildMinWidthNative(child: View): void {
|
public _setChildMinWidthNative(child: View, value: Length): void {
|
||||||
child._setMinWidthNative(0);
|
// Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804
|
||||||
|
if (!child._ignoreFlexMinWidthHeightReset) {
|
||||||
|
child._setMinWidthNative(0);
|
||||||
|
}
|
||||||
|
|
||||||
const nativeView = child.nativeViewProtected;
|
const nativeView = child.nativeViewProtected;
|
||||||
const lp = nativeView.getLayoutParams();
|
const lp = nativeView.getLayoutParams();
|
||||||
if (lp instanceof widgetLayoutParams) {
|
if (lp instanceof widgetLayoutParams) {
|
||||||
lp.minWidth = Length.toDevicePixels(child.style.minWidth, 0);
|
lp.minWidth = Length.toDevicePixels(value, 0);
|
||||||
nativeView.setLayoutParams(lp);
|
nativeView.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public _setChildMinHeightNative(child: View): void {
|
public _setChildMinHeightNative(child: View, value: Length): void {
|
||||||
child._setMinHeightNative(0);
|
// Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804
|
||||||
|
if (!child._ignoreFlexMinWidthHeightReset) {
|
||||||
|
child._setMinHeightNative(0);
|
||||||
|
}
|
||||||
|
|
||||||
const nativeView = child.nativeViewProtected;
|
const nativeView = child.nativeViewProtected;
|
||||||
const lp = nativeView.getLayoutParams();
|
const lp = nativeView.getLayoutParams();
|
||||||
if (lp instanceof widgetLayoutParams) {
|
if (lp instanceof widgetLayoutParams) {
|
||||||
lp.minHeight = Length.toDevicePixels(child.style.minHeight, 0);
|
lp.minHeight = Length.toDevicePixels(value, 0);
|
||||||
nativeView.setLayoutParams(lp);
|
nativeView.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,4 @@
|
|||||||
"android": "5.0.0"
|
"android": "5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import android.graphics.Rect;
|
|||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hhristov on 8/23/16.
|
* Created by hhristov on 8/23/16.
|
||||||
@ -22,6 +23,10 @@ public class ViewHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setMinWidth(android.view.View view, int value) {
|
public static void setMinWidth(android.view.View view, int value) {
|
||||||
|
if (view instanceof TextView) {
|
||||||
|
((android.widget.TextView) view).setMinWidth(value);
|
||||||
|
}
|
||||||
|
|
||||||
view.setMinimumWidth(value);
|
view.setMinimumWidth(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +35,10 @@ public class ViewHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setMinHeight(android.view.View view, int value) {
|
public static void setMinHeight(android.view.View view, int value) {
|
||||||
|
if (view instanceof TextView) {
|
||||||
|
((android.widget.TextView) view).setMinHeight(value);
|
||||||
|
}
|
||||||
|
|
||||||
view.setMinimumHeight(value);
|
view.setMinimumHeight(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,10 +56,10 @@ public class ViewHelper {
|
|||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = new CommonLayoutParams();
|
params = new CommonLayoutParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
params.width = value;
|
params.width = value;
|
||||||
if (params instanceof CommonLayoutParams) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
((CommonLayoutParams)params).widthPercent = -1;
|
((CommonLayoutParams) params).widthPercent = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
@ -65,7 +74,9 @@ public class ViewHelper {
|
|||||||
if (params instanceof CommonLayoutParams) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
CommonLayoutParams lp = (CommonLayoutParams) params;
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
lp.widthPercent = value;
|
lp.widthPercent = value;
|
||||||
lp.width = (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
|
lp.width = (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL
|
||||||
|
? ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
: ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,10 +95,10 @@ public class ViewHelper {
|
|||||||
if (params == null) {
|
if (params == null) {
|
||||||
params = new CommonLayoutParams();
|
params = new CommonLayoutParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
params.height = value;
|
params.height = value;
|
||||||
if (params instanceof CommonLayoutParams) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
((CommonLayoutParams)params).heightPercent = -1;
|
((CommonLayoutParams) params).heightPercent = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
@ -102,7 +113,9 @@ public class ViewHelper {
|
|||||||
if (params instanceof CommonLayoutParams) {
|
if (params instanceof CommonLayoutParams) {
|
||||||
CommonLayoutParams lp = (CommonLayoutParams) params;
|
CommonLayoutParams lp = (CommonLayoutParams) params;
|
||||||
lp.heightPercent = value;
|
lp.heightPercent = value;
|
||||||
lp.height = (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
|
lp.height = (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL
|
||||||
|
? ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
: ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,14 +334,14 @@ public class ViewHelper {
|
|||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
if (Gravity.isHorizontal(lp.gravity)) {
|
if (Gravity.isHorizontal(lp.gravity)) {
|
||||||
switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
||||||
case Gravity.LEFT:
|
case Gravity.LEFT:
|
||||||
return "left";
|
return "left";
|
||||||
case Gravity.CENTER:
|
case Gravity.CENTER:
|
||||||
return "center";
|
return "center";
|
||||||
case Gravity.RIGHT:
|
case Gravity.RIGHT:
|
||||||
return "right";
|
return "right";
|
||||||
case Gravity.FILL_HORIZONTAL:
|
case Gravity.FILL_HORIZONTAL:
|
||||||
return "stretch";
|
return "stretch";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -348,19 +361,19 @@ public class ViewHelper {
|
|||||||
if (params instanceof FrameLayout.LayoutParams) {
|
if (params instanceof FrameLayout.LayoutParams) {
|
||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "left":
|
case "left":
|
||||||
lp.gravity = Gravity.LEFT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
lp.gravity = Gravity.LEFT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
case "center":
|
case "center":
|
||||||
case "middle":
|
case "middle":
|
||||||
lp.gravity = Gravity.CENTER_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
lp.gravity = Gravity.CENTER_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
case "right":
|
case "right":
|
||||||
lp.gravity = Gravity.RIGHT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
lp.gravity = Gravity.RIGHT | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
case "stretch":
|
case "stretch":
|
||||||
lp.gravity = Gravity.FILL_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
lp.gravity = Gravity.FILL_HORIZONTAL | (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
@ -372,14 +385,14 @@ public class ViewHelper {
|
|||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
if (Gravity.isHorizontal(lp.gravity)) {
|
if (Gravity.isHorizontal(lp.gravity)) {
|
||||||
switch (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK) {
|
switch (lp.gravity & Gravity.VERTICAL_GRAVITY_MASK) {
|
||||||
case Gravity.TOP:
|
case Gravity.TOP:
|
||||||
return "top";
|
return "top";
|
||||||
case Gravity.CENTER:
|
case Gravity.CENTER:
|
||||||
return "center";
|
return "center";
|
||||||
case Gravity.BOTTOM:
|
case Gravity.BOTTOM:
|
||||||
return "bottom";
|
return "bottom";
|
||||||
case Gravity.FILL_VERTICAL:
|
case Gravity.FILL_VERTICAL:
|
||||||
return "stretch";
|
return "stretch";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,19 +412,19 @@ public class ViewHelper {
|
|||||||
if (params instanceof FrameLayout.LayoutParams) {
|
if (params instanceof FrameLayout.LayoutParams) {
|
||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "top":
|
case "top":
|
||||||
lp.gravity = Gravity.TOP | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
lp.gravity = Gravity.TOP | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
case "center":
|
case "center":
|
||||||
case "middle":
|
case "middle":
|
||||||
lp.gravity = Gravity.CENTER_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
lp.gravity = Gravity.CENTER_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
case "bottom":
|
case "bottom":
|
||||||
lp.gravity = Gravity.BOTTOM | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
lp.gravity = Gravity.BOTTOM | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
case "stretch":
|
case "stretch":
|
||||||
lp.gravity = Gravity.FILL_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
lp.gravity = Gravity.FILL_VERTICAL | (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
@ -480,7 +493,7 @@ public class ViewHelper {
|
|||||||
public static void setRotateY(android.view.View view, float value) {
|
public static void setRotateY(android.view.View view, float value) {
|
||||||
view.setRotationY(value);
|
view.setRotationY(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPerspective(android.view.View view, float value) {
|
public static void setPerspective(android.view.View view, float value) {
|
||||||
view.setCameraDistance(value);
|
view.setCameraDistance(value);
|
||||||
}
|
}
|
||||||
@ -549,4 +562,3 @@ public class ViewHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,4 +34,4 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user