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 bad5a55861..81fe75f646 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 @@ -268,6 +268,8 @@ class RoomDetailFragment @Inject constructor( } private const val ircPattern = " (IRC)" + + const val TARGET_SCROLL_OUT_FACTOR = 7f/8f } private val galleryOrCameraDialogHelper = GalleryOrCameraDialogHelper(this, colorProvider) @@ -835,10 +837,10 @@ class RoomDetailFragment @Inject constructor( scrollOnHighlightedEventCallback.scheduleScrollTo(action.eventId) } else { views.timelineRecyclerView.stopScroll() - // 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 + // Scroll such that the scrolled-to event is moved down (1-TARGET_SCROLL_OUT_FACTOR) of the screen. + // To do that, we actually scroll the view above out by TARGET_SCROLL_OUT_FACTOR (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) + layoutManager.scrollToPositionWithOffset(scrollPosition + 1, (views.timelineRecyclerView.measuredHeight * TARGET_SCROLL_OUT_FACTOR).toInt()) } } 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 6f84854223..a1b28003a3 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 @@ -66,11 +66,11 @@ class ScrollOnNewMessageCallback(private val layoutManager: LinearLayoutManager, layoutManager.scrollToPositionWithOffset(0, 0) } else { timelineEventController.searchPositionOfEvent(scrollToEvent)?.let { - // 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 + // Scroll such that the scrolled-to event is moved down (1-TARGET_SCROLL_OUT_FACTOR) of the screen. + // To do that, we actually scroll the view above out by TARGET_SCROLL_OUT_FACTOR (since we can only control the distance // from the bottom of the view, not the top). val scrollToPosition = max(it + scrollOffset + 1, 0) - layoutManager.scrollToPositionWithOffset(scrollToPosition, parentView.measuredHeight * 2 / 3) + layoutManager.scrollToPositionWithOffset(scrollToPosition, (parentView.measuredHeight * RoomDetailFragment.TARGET_SCROLL_OUT_FACTOR).toInt()) } } return