View recycler scroll to specific position

I have a custom recyclerview with a Holder view. I have one search. I want to move the view position of the recycler according to the search text of the search. How can I achieve this goal? so the search filter will be executed and according to the filtering I will get the position of the filtered text. and using that i can move focus (scroll) to that position.

thank

+3


source to share


1 answer


Try the following:

myRecyclerview.scrollToPosition(position);

      



if it doesn't work in some cases (keyboard opening, etc.) try using a delay.

new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
         myRecyclerview.scrollToPosition(position);
    }
 }, 200);

      

+3


source







All Articles