Open vinayjoglekar opened 6 years ago
Try this code
adapter.setOnTreeNodeListener(new TreeViewAdapter.OnTreeNodeListener() {
@Override
public boolean onClick(TreeNode node, RecyclerView.ViewHolder holder) {
if (!node.isLeaf()) {
onToggle(!node.isExpand(), holder);
int position = holder.getAdapterPosition();
int distanceInPixels;
View firstVisibleChild = rv.getChildAt(0);
int itemHeight = firstVisibleChild.getHeight();
int currentPosition = rv.getChildAdapterPosition(firstVisibleChild);
int p = Math.abs(position - currentPosition);
if (p > 5) distanceInPixels = (p - (p - 5)) * itemHeight;
else distanceInPixels = p * itemHeight;
linearLayoutManager.scrollToPositionWithOffset(position, distanceInPixels);
}
return false;
}
});
Hi Team, I am trying to implement a functionality where I can scroll up and expand childs of node on click of node whose all childs are not visible on screen. Please help me if there is any workaround for the same.
Thanks in advance.