Get x/y positions of nth item in RecyclerView

前端 未结 2 1488
不知归路
不知归路 2020-12-16 13:51

I would like to know how to get the X or Y position of nth item in RecyclerView. This is easy to do if the item is currently within the visible range. However, when the view

2条回答
  •  独厮守ぢ
    2020-12-16 14:42

    I got perfect x and y of every item in recycler view using following:

    int[] originalPos = new int[2];
    view.getLocationInWindow(originalPos);
    //or view.getLocationOnScreen(originalPos)
    int x = originalPos[0];
    int y = originalPos[1];
    

提交回复
热议问题