我的 BottomAppBar 覆盖了我的 RecyclerView 的最后一行
My BottomAppBar is covering the last row in my RecyclerView
我的 reclerview 的最后一行被我的底部应用栏覆盖了。
我的代码如下:
activity_home.xml
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@id/Container_fromHomeActivity_BottomAppBarFragments"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="@bool/Navigation_NavigationHost_Default"
app:navGraph="@navigation/bottomappbar_navigation"/>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@id/BottomAppBar_fromHomeActivity_Main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:fabAlignmentMode="center"
app:navigationIcon="@drawable/ic_menu_dark"
app:menu="@menu/menu_bottomappbar_main"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@id/FAB_fromHomeActivity_BottomAppBarAttached"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_dark"
android:backgroundTint="@color/colorAccent"
app:layout_anchor="@id/BottomAppBar_fromHomeActivity_Main"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
我的 reclerview 在我家的片段中 activity:
fragment.xml
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/todoList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
然而,最后一行只有一半可见:
根据 material 准则,底部应用栏和 FAB 应该位于协调器布局内,以便它们协同工作。那么我应该如何将我的 recyclerview 提升到底部应用栏上方,以便最后一行也可见?
我不想在末尾添加填充或边距,因为它似乎不是很好的编码...
请帮忙!
快速修复:
尝试使用这些属性:
<androidx.constraintlayout.widget.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/todoList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
我在我的 RecyclerView 上使用了 android:layout_marginBottom="?attr/actionBarSize"
,它起作用了...谢谢
尝试将recyclerView的约束添加到父级的底部
app:layout_constraintBottom_toBottomof="parent"
我的 reclerview 的最后一行被我的底部应用栏覆盖了。
我的代码如下:
activity_home.xml
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@id/Container_fromHomeActivity_BottomAppBarFragments"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="@bool/Navigation_NavigationHost_Default"
app:navGraph="@navigation/bottomappbar_navigation"/>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@id/BottomAppBar_fromHomeActivity_Main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:fabAlignmentMode="center"
app:navigationIcon="@drawable/ic_menu_dark"
app:menu="@menu/menu_bottomappbar_main"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@id/FAB_fromHomeActivity_BottomAppBarAttached"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_dark"
android:backgroundTint="@color/colorAccent"
app:layout_anchor="@id/BottomAppBar_fromHomeActivity_Main"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
我的 reclerview 在我家的片段中 activity:
fragment.xml
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/todoList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
然而,最后一行只有一半可见:
根据 material 准则,底部应用栏和 FAB 应该位于协调器布局内,以便它们协同工作。那么我应该如何将我的 recyclerview 提升到底部应用栏上方,以便最后一行也可见?
我不想在末尾添加填充或边距,因为它似乎不是很好的编码...
请帮忙!
快速修复:
尝试使用这些属性:
<androidx.constraintlayout.widget.ConstraintLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/todoList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="56dp"
android:clipToPadding="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
我在我的 RecyclerView 上使用了 android:layout_marginBottom="?attr/actionBarSize"
,它起作用了...谢谢
尝试将recyclerView的约束添加到父级的底部 app:layout_constraintBottom_toBottomof="parent"