width auto adapt
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/b450c5a0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/b450c5a0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/b450c5a0 Branch: refs/heads/0.16-dev Commit: b450c5a0b097887fa13b66f4c0c6dd362ee5be7c Parents: 2544b5e Author: jianbai.gbj <jianbai....@alibaba-inc.com> Authored: Thu Sep 14 20:08:48 2017 +0800 Committer: jianbai.gbj <jianbai....@alibaba-inc.com> Committed: Thu Sep 14 20:08:48 2017 +0800 ---------------------------------------------------------------------- .../com/taobao/weex/dom/WXCellDomObject.java | 9 +++++++++ .../com/taobao/weex/dom/WXRecyclerDomObject.java | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b450c5a0/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java index bb3694d..6d50ab6 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java @@ -55,6 +55,9 @@ public class WXCellDomObject extends WXDomObject { } if(slotDomObject.isSticky()){ float w = recyclerDomObject.getAvailableWidth(); + if(w <= 0){ + w = recyclerDomObject.getViewPortWidth(); + } node.setLayoutWidth(w); measureOutput.width = w; }else { @@ -64,6 +67,12 @@ public class WXCellDomObject extends WXDomObject { float w = recyclerDomObject.getColumnWidth(); if(w <= 0 && recyclerDomObject.getColumnCount() <= 1){ w = recyclerDomObject.getAvailableWidth(); + if(w <= 0){ + w = recyclerDomObject.getLayoutWidth(); + if(w <= 0){ + w = recyclerDomObject.getViewPortWidth(); + } + } } node.setLayoutWidth(w); measureOutput.width = w; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b450c5a0/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java index f873512..1ae3af2 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java @@ -34,7 +34,6 @@ import static com.taobao.weex.dom.flex.CSSLayout.DIMENSION_WIDTH; /** * Created by zhengshihan on 2017/2/21. */ - public class WXRecyclerDomObject extends WXDomObject{ @@ -79,13 +78,19 @@ public class WXRecyclerDomObject extends WXDomObject{ @Override public float getStyleWidth() { - if (Float.isNaN(cssstyle.dimensions[DIMENSION_WIDTH])){ - if(getParent() != null){ - return getParent().getLayoutWidth(); - } - return getViewPortWidth(); + float width = getLayoutWidth(); + if (Float.isNaN(width) || width <= 0){ + if(getParent() != null){ + width = getParent().getLayoutWidth(); + } + if (Float.isNaN(width) || width <= 0){ + width = super.getStyleWidth(); + } + } + if (Float.isNaN(width) || width <= 0){ + width = getViewPortWidth(); } - return super.getStyleWidth(); + return width; } public void preCalculateCellWidth(){