Reputation: 1
I have been using the code snippets for scrolling position after update
void scrollToPositionWithOffset(LinearLayoutManager layoutManager,
DetailItemData detailItemData,
int pxOffset) {
LogUtil.logI(TAG, "detailItemData=" + detailItemData.getClass().getName() + ", pxOffset=" + pxOffset);
final int dataIndex = detailAdapter.get().findIndexByViewData(detailItemData);
LogUtil.logI(TAG, "dataIndex: " + dataIndex);
if (dataIndex < 0) {
LogUtil.logE(TAG, "Can't find index. scroll to at(0).");
layoutManager.scrollToPositionWithOffset(0, pxOffset);
return;
}
layoutManager.scrollToPositionWithOffset(dataIndex, pxOffset);
}
layoutManager.scrollToPositionWithOffset(dataIndex, pxOffset);
Upvotes: 0
Views: 10