1

LinearLayoutManager provides a basic implementation for relocating items in the recycler. Assuming the following configuration in recyclerView:

E0 | E1 E2 E3 | E4

where | represents the effective bounds of recyclerView, a delete on E1 will result in the following final setting after all redrawing and animations:

E0 | E2 E3 E4 |

I need to accomplish a different behavior. Basically I want

| E0 E2 E3 | E4

a move of the other elements based on which part, left or right of the screen (relative to E2 in this case), I've made the delete. Basically the original center element must be taken as pivot for choosing which part to move.

Seems that this behavior is not easily achievable. Setting stackFromEnd doesn't resolve the problem because we have analog problem for removals on the opposite side. Also changing stackFromEnd value at runtime before effectively making the call to adapter.onItemRemoved doesn't resolve the problem.

4

1 回答 1

0

删除时,只需调用scrollToPositionWithOffset(adapterPositionOf(E2), offsetOf(E2)).

于 2016-01-27T00:47:28.050 回答