mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-15 18:59:12 +03:00
Scroll to top of messages again
We want to specify where to scroll to from the top of the message rather than the bottom. To do this in a recycler view that's filled from the bottom, let's just target the event above and move that out by 2/3 of the screen. Change-Id: Ica8ec2d0aaa22b654232f128992510c9d550fe35
This commit is contained in:
parent
3af5e6ea76
commit
401424ff96
2 changed files with 8 additions and 3 deletions
|
@ -835,7 +835,10 @@ class RoomDetailFragment @Inject constructor(
|
|||
scrollOnHighlightedEventCallback.scheduleScrollTo(action.eventId)
|
||||
} else {
|
||||
views.timelineRecyclerView.stopScroll()
|
||||
layoutManager.scrollToPosition(scrollPosition)
|
||||
// Scroll such that the scrolled-to event is moved down 1/3 of the screen.
|
||||
// To do that, we actually scroll the view above out by 2/3 (since we can only control the distance
|
||||
// from the bottom of the view, not the top).
|
||||
layoutManager.scrollToPositionWithOffset(scrollPosition + 1, views.timelineRecyclerView.measuredHeight * 2 / 3)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,8 +64,10 @@ class ScrollOnNewMessageCallback(private val layoutManager: LinearLayoutManager,
|
|||
layoutManager.scrollToPositionWithOffset(0, 0)
|
||||
} else {
|
||||
timelineEventController.searchPositionOfEvent(scrollToEvent)?.let {
|
||||
// Scroll such that the scrolled-to event is moved up 1/4 of the screen
|
||||
layoutManager.scrollToPositionWithOffset(it, parentView.measuredHeight / 4)
|
||||
// Scroll such that the scrolled-to event is moved down 1/3 of the screen.
|
||||
// To do that, we actually scroll the view above out by 2/3 (since we can only control the distance
|
||||
// from the bottom of the view, not the top).
|
||||
layoutManager.scrollToPositionWithOffset(it + 1, parentView.measuredHeight * 2 / 3)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue