修复目录最后一项视图被遮挡的问题
This commit is contained in:
1 parent
1a2bd5f431
commit
bc9bd557bb
2 files changed
+77
-54
No files matched your search
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.Activity.RESULT_OK
|
import android.app.Activity.RESULT_OK
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Rect
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@@ -27,7 +28,7 @@ import io.legato.kazusa.model.CacheBook
|
|||||||
import io.legato.kazusa.ui.widget.recycler.UpLinearLayoutManager
|
import io.legato.kazusa.ui.widget.recycler.UpLinearLayoutManager
|
||||||
import io.legato.kazusa.ui.widget.recycler.VerticalDivider
|
import io.legato.kazusa.ui.widget.recycler.VerticalDivider
|
||||||
import io.legato.kazusa.utils.VibrationUtils
|
import io.legato.kazusa.utils.VibrationUtils
|
||||||
import io.legato.kazusa.utils.applyNavigationBarMargin
|
import io.legato.kazusa.utils.applyNavigationBarPadding
|
||||||
import io.legato.kazusa.utils.dpToPx
|
import io.legato.kazusa.utils.dpToPx
|
||||||
import io.legato.kazusa.utils.observeEvent
|
import io.legato.kazusa.utils.observeEvent
|
||||||
import io.legato.kazusa.utils.themeColor
|
import io.legato.kazusa.utils.themeColor
|
||||||
@@ -147,11 +148,24 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
|
|||||||
|
|
||||||
binding.recyclerView.layoutManager = mLayoutManager
|
binding.recyclerView.layoutManager = mLayoutManager
|
||||||
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
|
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
|
||||||
|
binding.recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||||
|
override fun getItemOffsets(
|
||||||
|
outRect: Rect,
|
||||||
|
view: View,
|
||||||
|
parent: RecyclerView,
|
||||||
|
state: RecyclerView.State
|
||||||
|
) {
|
||||||
|
if (parent.getChildAdapterPosition(view) == state.itemCount - 1) {
|
||||||
|
outRect.bottom = 80.dpToPx()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
binding.recyclerView.adapter = adapter
|
binding.recyclerView.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() = binding.run {
|
private fun initView() = binding.run {
|
||||||
cdBase.applyNavigationBarMargin()
|
llBase.applyNavigationBarPadding()
|
||||||
btnChapterTop.setOnClickListener {
|
btnChapterTop.setOnClickListener {
|
||||||
mLayoutManager.scrollToPositionWithOffset(0, 0)
|
mLayoutManager.scrollToPositionWithOffset(0, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,68 +13,77 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<LinearLayout
|
||||||
android:id="@+id/cd_base"
|
android:id="@+id/ll_base"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="16dp"
|
android:orientation="horizontal"
|
||||||
app:cardBackgroundColor="?attr/colorSurfaceContainer"
|
|
||||||
app:cardElevation="8dp"
|
|
||||||
app:strokeWidth="0dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent">
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/ll_chapter_base_info"
|
android:id="@+id/cd_base"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:orientation="horizontal"
|
android:layout_marginVertical="8dp"
|
||||||
android:paddingVertical="8dp"
|
app:cardBackgroundColor="?attr/colorSurfaceContainer"
|
||||||
android:paddingStart="16dp"
|
app:cardElevation="4dp"
|
||||||
android:paddingEnd="10dp">
|
app:strokeWidth="0dp">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tv_current_chapter_info"
|
android:id="@+id/ll_chapter_base_info"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:gravity="center"
|
||||||
android:gravity="center_vertical"
|
android:orientation="horizontal"
|
||||||
android:singleLine="true"
|
android:paddingVertical="8dp"
|
||||||
android:textSize="12sp"
|
android:paddingStart="16dp"
|
||||||
android:textStyle="bold" />
|
android:paddingEnd="10dp">
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<TextView
|
||||||
android:id="@+id/btn_locate"
|
android:id="@+id/tv_current_chapter_info"
|
||||||
style="@style/Widget.Material3Expressive.Button.IconButton.Outlined"
|
android:layout_width="0dp"
|
||||||
android:layout_width="40dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_weight="1"
|
||||||
android:contentDescription="@string/locate_current"
|
android:gravity="center_vertical"
|
||||||
app:icon="@drawable/ic_locate"
|
android:singleLine="true"
|
||||||
app:iconGravity="textStart"
|
android:textSize="12sp"
|
||||||
app:iconPadding="0dp"
|
android:textStyle="bold" />
|
||||||
app:iconSize="16dp" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_chapter_top"
|
android:id="@+id/btn_locate"
|
||||||
style="@style/Widget.Material3Expressive.Button.IconButton.Tonal"
|
style="@style/Widget.Material3Expressive.Button.IconButton.Outlined"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:contentDescription="@string/go_to_top"
|
android:contentDescription="@string/locate_current"
|
||||||
app:icon="@drawable/ic_arrow_drop_up"
|
app:icon="@drawable/ic_locate"
|
||||||
app:iconGravity="textStart"
|
app:iconGravity="textStart"
|
||||||
app:iconPadding="0dp" />
|
app:iconPadding="0dp"
|
||||||
|
app:iconSize="16dp" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_chapter_bottom"
|
android:id="@+id/btn_chapter_top"
|
||||||
style="@style/Widget.Material3Expressive.Button.IconButton.Tonal"
|
style="@style/Widget.Material3Expressive.Button.IconButton.Tonal"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:contentDescription="@string/go_to_bottom"
|
android:contentDescription="@string/go_to_top"
|
||||||
app:icon="@drawable/ic_arrow_drop_down"
|
app:icon="@drawable/ic_arrow_drop_up"
|
||||||
app:iconGravity="textStart"
|
app:iconGravity="textStart"
|
||||||
app:iconPadding="0dp" />
|
app:iconPadding="0dp" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn_chapter_bottom"
|
||||||
|
style="@style/Widget.Material3Expressive.Button.IconButton.Tonal"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:contentDescription="@string/go_to_bottom"
|
||||||
|
app:icon="@drawable/ic_arrow_drop_down"
|
||||||
|
app:iconGravity="textStart"
|
||||||
|
app:iconPadding="0dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in new issue
Block a user