2
votes

Mon BottomAppBar couvre la dernière ligne de mon RecyclerView

La dernière ligne de ma reclerview est couverte par ma barre d'application inférieure.

Mon code est le suivant:

activity_home.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>

Ma reclerview est dans un fragment de mon activité à domicile:

fragment.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>

Cependant, la dernière ligne n'est qu'à moitié visible en tant que telle: p>

 RecyclerView

D'après les directives relatives aux matériaux, la barre d'applications inférieure et FAB DEVRAIENT être dans une mise en page de coordination pour qu'ils puissent travailler ensemble. Alors, comment suis-je censé élever ma vue de recyclage au-dessus de la barre d'application inférieure pour que la dernière ligne soit également visible?

Je ne veux pas ajouter de remplissage ou de marge à la fin, car cela ne semble pas soyez un bon codage ...

S'il vous plaît, aidez!


3 commentaires

Copie possible de Comment ajouter des marges à un RecyclerView pour le dernier élément?


Je ne veux pas ajouter de remplissage, je veux qu'il soit au-dessus de la barre d'application inférieure afin que la dernière ligne soit visible.


L'idée est d'ajouter une marge inférieure à RecyclerView afin qu'elle reste au-dessus de la barre de navigation inférieure.


3 Réponses :


0
votes

Solution rapide:

Essayez avec ces attributs:

<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>


3 commentaires

Je ne veux pas ajouter de remplissage, je veux qu'il soit au-dessus de la barre d'application inférieure afin que la dernière ligne soit visible. Ajouter un rembourrage ne semble pas être une bonne façon de procéder ...


Ouais, que diriez-vous de la marge inférieure de votre fragment


J'ai utilisé android: layout_marginBottom = "? Attr / actionBarSize" sur mon recyclerview et cela a fonctionné! Merci.



1
votes

J'ai utilisé android: layout_marginBottom = "? attr / actionBarSize" sur mon RecyclerView et cela a fonctionné ... Merci


0 commentaires

0
votes

Essayez d'ajouter une contrainte pour recyclerView au bas du parent app: layout_constraintBottom_toBottomof = "parent"


0 commentaires