diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt index 45a409b32..4ad7d64f6 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt @@ -10,6 +10,7 @@ import androidx.appcompat.widget.Toolbar import androidx.core.os.bundleOf import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.base.BaseDialogFragment @@ -213,7 +214,8 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_ private fun scrollToDurSource() { adapter.getItems().forEachIndexed { index, searchBook -> if (searchBook.bookUrl == bookUrl) { - binding.recyclerView.scrollToPosition(index) + (binding.recyclerView.layoutManager as LinearLayoutManager) + .scrollToPositionWithOffset(index, 60.dpToPx()) return } } diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt index f46f3cab0..303fac5af 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt @@ -10,6 +10,7 @@ import androidx.core.os.bundleOf import androidx.core.view.isVisible import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.base.BaseDialogFragment @@ -247,7 +248,8 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c private fun scrollToDurSource() { searchBookAdapter.getItems().forEachIndexed { index, searchBook -> if (searchBook.bookUrl == bookUrl) { - binding.recyclerView.scrollToPosition(index) + (binding.recyclerView.layoutManager as LinearLayoutManager) + .scrollToPositionWithOffset(index, 60.dpToPx()) return } }