Hippy icon indicating copy to clipboard operation
Hippy copied to clipboard

Android 3.3.0 版本自定义高度计算为 0,2.x 版本都没有问题,切换为 3.3.0 版本后按照文档升级,自定义控件高度始终为 0

Open ShaXiaQAQ opened this issue 1 year ago • 0 comments

Describe the bug 升级 3.0 后,自定义控件高度一直为 0,在 createRenderNode 的时候打印前端传过来的 Props 里面高度是有的,Debug 发现在NativeRenderProvider中的以下方法中,解析出来的 list 高度直接为 0,导致后面步骤获取出来的值也是 0:

@CalledByNative public void callUIFunction(int rootId, int nodeId, long callbackId, String functionName, byte[] buffer) { NativeRenderDelegate renderDelegate = (NativeRenderDelegate)this.mRenderDelegateRef.get(); if (renderDelegate != null) { try { List<Object> list = this.bytesToArgument(ByteBuffer.wrap(buffer)); renderDelegate.callUIFunction(rootId, nodeId, callbackId, functionName, list); } catch (NativeRenderException var9) { renderDelegate.handleRenderException(var9); } }

}

To Reproduce Steps to reproduce the behavior:

  1. 自定义一个控件,继承 CardView 或者别的 VIew;

  2. 在自定义控件中使用和官方 Pager 同样实现计算和布局: private val measureAndLayout = Runnable { if (readyToLayout()) { measure( MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY) ) LogUtil.d("hippy:::measureAndLayout:::$width:::$height:::$left:::$top:::$right:::$bottom") layout(left, top, right, bottom) } } override fun requestLayout() { super.requestLayout() triggerRequestLayout() } fun bindData(data: List? = null) { setdata(data) triggerRequestLayout() }

  3. 最终控件宽度正常,为vue 前端设置的值,高度为 0;

  4. Go to '...'

  5. Click on '....'

  6. Scroll down to '....'

  7. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS and version: [e.g. iOS 13.3.1]
  • Hippy native SDK version: [e.g. 2.0.0]
  • Front-end SDK and version [e.g. @hippy/vue 2.0.1]

Additional context Add any other context about the problem here.

ShaXiaQAQ avatar Jul 04 '24 06:07 ShaXiaQAQ