本文整理汇总了Java中com.taobao.weex.WXEnvironment.sDefaultWidth方法的典型用法代码示例。如果您正苦于以下问题:Java WXEnvironment.sDefaultWidth方法的具体用法?Java WXEnvironment.sDefaultWidth怎么用?Java WXEnvironment.sDefaultWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.weex.WXEnvironment
的用法示例。
在下文中一共展示了WXEnvironment.sDefaultWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRealPxByWidth
import com.taobao.weex.WXEnvironment; //导入方法依赖的package包/类
/**
* Convert distance from JS,CSS to native. As the JS considers the width of the screen is 750px.
* There must be a transform when accessing distance from JS,CSS and use it.
* Basically, this method calculates a scale factor(ScreenWidth/750) and use apply this scale
* factor to JS,CSS distance.
* @param pxValue the raw distance from JS or CSS. The result will be rounded to a closet int.
* @return the actual distance in the screen.
*/
public static float getRealPxByWidth(float pxValue) {
if (Float.isNaN(pxValue)) {
return pxValue;
}
if (mUseWebPx) {
return (float) Math.rint(pxValue);
} else {
float realPx = (pxValue * getScreenWidth() / WXEnvironment.sDefaultWidth);
return realPx > 0.005 && realPx < 1 ? 1 : (float) Math.rint(realPx);
}
}
示例2: getRealSubPxByWidth
import com.taobao.weex.WXEnvironment; //导入方法依赖的package包/类
public static float getRealSubPxByWidth(float pxValue) {
if (Float.isNaN(pxValue)) {
return pxValue;
}
if (mUseWebPx) {
return (float) Math.rint(pxValue);
} else {
float realPx = (pxValue * getScreenWidth() / WXEnvironment.sDefaultWidth);
return realPx > 0.005 && realPx < 1 ? 1 : realPx;
}
}
示例3: getWeexPxByReal
import com.taobao.weex.WXEnvironment; //导入方法依赖的package包/类
/**
* Internal interface that just for debug, you should never call this method because of accuracy loss obviously
*/
public static float getWeexPxByReal(float pxValue) {
if (Float.isNaN(pxValue)) {
return pxValue;
}
if (mUseWebPx) {
return (float) Math.rint(pxValue);
} else {
return pxValue * WXEnvironment.sDefaultWidth / getScreenWidth();
}
}
示例4: getRealPxByWidth2
import com.taobao.weex.WXEnvironment; //导入方法依赖的package包/类
public static int getRealPxByWidth2(float pxValue) {
if (mUseWebPx) {
return (int) pxValue;
} else {
float realPx = (pxValue * getScreenWidth() / WXEnvironment.sDefaultWidth);
return realPx > 0.005 && realPx < 1 ? 1 : (int) realPx - 1;
}
}
示例5: getWebPxByWidth
import com.taobao.weex.WXEnvironment; //导入方法依赖的package包/类
/**
* Convert distance from native to JS,CSS. As the JS considers the width of the screen is 750px.
* There must be a transform when return distance to JS,CSS.
* Basically, this method calculates a scale factor(ScreenWidth/750) and use apply this scale
* factor to native distance.
* @param pxValue the raw distance of native. The result will be rounded to a closet int.
* @return the distance in JS,CSS where the screenWidth is 750 px.
*/
public static float getWebPxByWidth(float pxValue) {
if (pxValue < -1.9999 && pxValue > -2.005) {
return Float.NaN;
}
if (mUseWebPx) {
return pxValue;
} else {
float realPx = (pxValue * WXEnvironment.sDefaultWidth / getScreenWidth());
return realPx > 0.005 && realPx < 1 ? 1 : realPx;
}
}