I use recycleView
and to scroll to a particular view
position and show a popupWindow
below that view
, if layout is not scrolled then popupWindow
will not be shown at correct position since layout is not loaded. Recycleview's onScrollClickListener()
doesn't get triggered when using recyclerView.scrollToTopPosition(pos)
method. I have searched similar issue on stackoverflow and LayoutChangeListener()
is suggested, but that also fails to work in my case.
Is there any other suggstion how to get onScroll
callback when scrolling is done? I have been searching for a solution for the some hours now no luck.
My code
GenericFragmentButton fragmentButton = fragmentButtonsList.get(position).getFragmentButton();
int adapterPosition = groupAdapter.getAdapterPosition(fragmentButton);
layoutChangeListener = new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
showShowCase(position, fragmentButtonsList, fragmentButton);
}
};
recyclerView.addOnLayoutChangeListener(layoutChangeListener);
recyclerView.scrollToPosition(adapterPosition);
Showcase is supposed to show below the highlighted icon, but for some reasons when i use
addOnLayoutChangeListener()
it is shown at bottom, most of layout is hidden. I get this issue when i use addOnLayoutChangeListener()
only so that's the reason i am searching for an alternate way to detect on scroll complete.
Update: Displaying popupWindow
after a delay works but I don't think it's good solution.
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(() -> showShowCase(position, fragmentButtonsList, fragmentButton), 200);