Java Code Examples for com.taobao.weex.utils.WXViewUtils#getScreenWidth()

The following examples show how to use com.taobao.weex.utils.WXViewUtils#getScreenWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WXScroller.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected MeasureOutput measure(int width, int height) {
  MeasureOutput measureOutput = new MeasureOutput();
  if (this.mOrientation == Constants.Orientation.HORIZONTAL) {
    int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication);
    int weexW = WXViewUtils.getWeexWidth(getInstanceId());
    measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                       : width;
    measureOutput.height = height;
  } else {
    int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
    int weexH = WXViewUtils.getWeexHeight(getInstanceId());
    measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                         : height;
    measureOutput.width = width;
  }
  return measureOutput;
}
 
Example 2
Source File: WXScroller.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
protected MeasureOutput measure(int width, int height) {
  MeasureOutput measureOutput = new MeasureOutput();
  if (this.mOrientation == Constants.Orientation.HORIZONTAL) {
    int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication);
    int weexW = WXViewUtils.getWeexWidth(getInstanceId());
    measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                       : width;
    measureOutput.height = height;
  } else {
    int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
    int weexH = WXViewUtils.getWeexHeight(getInstanceId());
    measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                         : height;
    measureOutput.width = width;
  }
  return measureOutput;
}
 
Example 3
Source File: WXScroller.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
protected MeasureOutput measure(int width, int height) {
  MeasureOutput measureOutput = new MeasureOutput();
  if (this.mOrientation == WXVContainer.HORIZONTAL) {
    int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication);
    int weexW = WXViewUtils.getWeexWidth(mInstanceId);
    measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                       : width;
    measureOutput.height = height;
  } else {
    int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
    int weexH = WXViewUtils.getWeexHeight(mInstanceId);
    measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                         : height;
    measureOutput.width = width;
  }
  return measureOutput;
}
 
Example 4
Source File: WXSvgContainer.java    From Svg-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
public WXSvgContainer(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) {
  super(instance, dom, parent);
  mDom = dom;
  Log.v("WXSvgContainer", mDom.getAttrs().values().toString());
  if (mDom.getStyles().get(Constants.Name.HEIGHT) == null) {
    mDom.getStyles().put(Constants.Name.HEIGHT, "0");
  }
  if (mDom.getStyles().get(Constants.Name.WIDTH) == null) {
    mDom.getStyles().put(Constants.Name.WIDTH, "0");
  }
  mScale = (float) (WXViewUtils.getScreenWidth(parent.getContext()) * 1.0 / dom.getViewPortWidth());
}
 
Example 5
Source File: UWXNavBar.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void setData(UWXTheme.NavBar navBar) {
//        float weexPxByReal = WXViewUtils.getWeexPxByReal(navBar.height)/2;
        LayoutParams layoutParams = new LayoutParams(WXViewUtils.getScreenWidth(getContext()),
                DensityUtil.dip2px(getContext(), navBar.height / 2 - 5));
        this.setLayoutParams(layoutParams);
        this.textBack.setVisibility(navBar.hasBack ? VISIBLE : GONE);
        try {
            this.setBackgroundColor(Color.parseColor(navBar.navBarColor));
            this.textBack.setTextColor(Color.parseColor(navBar.backColor));
        } catch (IllegalArgumentException e) {
            UWLog.e(e.getMessage());
        }

    }
 
Example 6
Source File: WXSvgAbsComponent.java    From Svg-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
public WXSvgAbsComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) {
  super(instance, dom, parent);
  mScale = (float) (WXViewUtils.getScreenWidth(parent.getContext()) * 1.0 / dom.getViewPortWidth());
}