Android ListView - stop scrolling at 'whole' row position

前端 未结 7 1451
生来不讨喜
生来不讨喜 2020-12-29 11:46

Sorry for the confusing title, I cannot express the problem very concisely...

I have an Android app with a ListView that uses a circular / \"infinite\" adapter, whi

7条回答
  •  情深已故
    2020-12-29 12:18

    If you can get the position of the row that needs to be scrolled to, you can use the method:

    smoothScrollToPosition

    So something like:

    int pos = lv.getFirstVisiblePosition();
    lv.smoothScrollToPosition(pos);
    

    Edit
    Try this, sorry I don't have time to test, I'm out and about.

    ImageView iv = //Code to find the image view
    Rect rect = new Rect(iv.getLeft(), iv.getTop(), iv.getRight(), iv.getBottom());
    lv.requestChildRectangleOnScreen(lv, rect, false);
    

提交回复
热议问题