WXListComponent extends WXVContainer<BounceRecyclerView> implements
        IRecyclerAdapterListener<ListBaseViewHolder>,IOnLoadMoreListener,Scrollable { @Override public void scrollTo(WXComponent component,final int offset) { if(bounceRecyclerView == null){ return; } WXComponent parent = component; WXCell cell = null; while(parent != null){ if(parent instanceof WXCell){ cell = (WXCell) parent; break; } parent = parent.getParent(); } if(cell !=null){ int pos = mChildren.indexOf(cell); final WXRecyclerView view = bounceRecyclerView.getInnerView(); view.scrollToPosition(pos); final WXComponent cellComp = cell; view.postDelayed(new Runnable() { @Override public void run() { if(getOrientation() == Constants.Orientation.VERTICAL){ int scrollY = cellComp.getHostView().getTop()+offset; view.smoothScrollBy(0,scrollY ); }else{ int scrollX = cellComp.getHostView().getLeft()+offset; view.smoothScrollBy(scrollX,0); } } },50); onPostScrollToPosition(pos); } } @Deprecated  WXListComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy);  WXListComponent(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override void destroy(); @Override void bindStickStyle(WXComponent component); @Override void unbindStickStyle(WXComponent component); @Override void bindAppearEvent(WXComponent component); @Override void bindDisappearEvent(WXComponent component); @Override void unbindAppearEvent(WXComponent component); @Override void unbindDisappearEvent(WXComponent component); @Override void scrollTo(WXComponent component,final int offset); void checkLastSticky(final int position); @Override void onBeforeScroll(int dx, int dy); @Override int getScrollY(); @Override int getScrollX(); @Override void addChild(WXComponent child); @Override void addChild(WXComponent child, int index); @Override void remove(WXComponent child); @Override void remove(WXComponent child, boolean destroy); @Override void computeVisiblePointInViewCoordinate(PointF pointF); @Override void onViewRecycled(ListBaseViewHolder holder); @Override void onBindViewHolder(ListBaseViewHolder holder, int position); @Override ListBaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType); @Override int getItemViewType(int position); @Override int getItemCount(); @Override boolean onFailedToRecycleView(ListBaseViewHolder holder); @Override long getItemId(int position); @Override void onLoadMore(int offScreenY); @Override void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY); static final String TRANSFORM; static final String LOADMOREOFFSET; }
@Test public void testScrollTo() throws Exception { WXComponent child = WXDivTest.create(component); ComponentTest.create(child); component.addChild(child); child = WXHeaderTest.create(component); ComponentTest.create(child); component.addChild(child); component.scrollTo(child,0); }