From d3584fcc4f1a68681c0a2a03df2a54802851a7fc Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 4 May 2020 15:32:01 -0400 Subject: [PATCH] Fixed fast scroll text layout closes #278 --- .../kanade/tachiyomi/ui/library/LibraryController.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index ac3e2f0324..e10c6eb25c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -174,14 +174,21 @@ class LibraryController( setActiveCategory() if (presenter.categories.size > 1 && dy != 0) { val headerItem = getHeader() ?: return - val view = fast_scroller?.getChildAt(0) ?: return + val view = fast_scroller ?: return + + val height = if (view.childCount > 0) { + view.height - (view.getChildAt(0)?.paddingTop ?: 0) - + (view.getChildAt(view.childCount - 1)?.paddingBottom ?: 0) + } else { + view.height + } val index = adapter.headerItems.indexOf(headerItem) textAnim?.cancel() textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(2000) textAnim?.start() // fastScroll height * indicator position - center text - fastScroll padding - text_view_m.translationY = view.height * + text_view_m.translationY = height * (index.toFloat() / (adapter.headerItems.size + 1)) - text_view_m.height / 2 + 16.dpToPx text_view_m.translationX = 45f.dpToPxEnd