本文整理匯總了TypeScript中utils/utils.layout.getMeasureSpecSize方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript layout.getMeasureSpecSize方法的具體用法?TypeScript layout.getMeasureSpecSize怎麽用?TypeScript layout.getMeasureSpecSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils/utils.layout
的用法示例。
在下文中一共展示了layout.getMeasureSpecSize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: onMeasure
onMeasure(widthMeasureSpec, heightMeasureSpec) {
let utils = require("utils/utils"),
width = utils.layout.getMeasureSpecSize(widthMeasureSpec),
widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec),
height = utils.layout.getMeasureSpecSize(heightMeasureSpec),
heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec),
nativeWidth = this.nativeView ? (this.nativeView.image ? this.nativeView.image.size.width : 0) : 0,
nativeHeight = this.nativeView ? (this.nativeView.image ? this.nativeView.image.size.height : 0) : 0,
measureWidth = Math.max(nativeWidth, this.minWidth as number),
measureHeight = Math.max(nativeHeight, this.minHeight as number),
finiteWidth = widthMode !== utils.layout.UNSPECIFIED,
finiteHeight = heightMode !== utils.layout.UNSPECIFIED;
if (nativeWidth !== 0 && nativeHeight !== 0 && (finiteWidth || finiteHeight)) {
let scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.stretch),
resultW = Math.floor(nativeWidth * scale.width),
resultH = Math.floor(nativeHeight * scale.height);
measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;
let trace = require("trace");
trace.write("Image stretch: " + this.stretch +
", nativeWidth: " + nativeWidth +
", nativeHeight: " + nativeHeight, trace.categories.Layout);
}
let view = require("ui/core/view");
let widthAndState = view.View.resolveSizeAndState(measureWidth, width, widthMode, 0);
let heightAndState = view.View.resolveSizeAndState(measureHeight, height, heightMode, 0);
this.setMeasuredDimension(widthAndState, heightAndState);
}
示例2: onMeasure
// This method won't be called in Android because we use the native android layout.
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
var result = view.View.measureChild(this, this.layoutView, widthMeasureSpec, heightMeasureSpec);
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
var density = utils.layout.getDisplayDensity();
var measureWidth = Math.max(result.measuredWidth, this.minWidth * density);
var measureHeight = Math.max(result.measuredHeight, this.minHeight * density);
var widthAndState = view.View.resolveSizeAndState(measureWidth, width, widthMode, 0);
var heightAndState = view.View.resolveSizeAndState(measureHeight, height, heightMode, 0);
this.setMeasuredDimension(widthAndState, heightAndState);
}