You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/11/02 09:28:41 UTC

[GitHub] liushengyi commented on issue #1639: android 自定义的components,必须设置高度吗,有没有办法不设置高度,自动适应的

liushengyi commented on issue #1639: android 自定义的components,必须设置高度吗,有没有办法不设置高度,自动适应的 
URL: https://github.com/apache/incubator-weex/issues/1639#issuecomment-435320724
 
 
   可以控件onLayout完成之后,手动设置控件宽高。按照WXComponent 中的updateStyleByPesudo的写法,可以实现自适应宽高。
   
    public void updateSize(float width, float height) {
           GraphicPosition lp = getLayoutPosition();
           updateDemission(lp.getTop(), lp.getTop() + height, lp.getLeft(), lp.getLeft() + width, height, width);
           Map<String, Object> styles = new HashMap<>(4);
           styles.put(com.taobao.weex.common.Constants.Name.TOP, lp.getTop());
           styles.put(com.taobao.weex.common.Constants.Name.BOTTOM, lp.getBottom());
           styles.put(com.taobao.weex.common.Constants.Name.LEFT, lp.getLeft());
           styles.put(com.taobao.weex.common.Constants.Name.RIGHT, lp.getRight());
           updateStyle(styles);
       }
   
       private void updateStyle(Map<String, Object> styles) {
           new GraphicActionUpdateStyle(getInstance(), getRef(), styles, getPadding(), getMargin(), getBorder(), false)
                   .executeActionOnRender();
           if (getLayoutWidth() == 0 && getLayoutWidth() == 0) {
           } else {
               WXBridgeManager.getInstance().setStyleWidth(getInstanceId(), getRef(), getLayoutWidth());
               WXBridgeManager.getInstance().setStyleHeight(getInstanceId(), getRef(), getLayoutHeight());
           }
       }
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services