diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index e74e3e3c7d..bad5a55861 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -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) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt index 7df3ed347e..eb2fa203b0 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt @@ -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