-1
votes

Aligner le texte dans RecyclERView avec des titres

Bonjour j'ai fait un recyclerview avec des commandes. Mais la liste dans la popup n'est pas alignée sur les titres. Parce que les images disent plus que des mots, vous pouvez le voir ici:

 Entrez la description de l'image ici p>

mais ce dont j'ai besoin, c'est quelque chose comme ça: P>

Entrez la description de l'image ici p>

Comment pourrais-je faire ce travail? Comment puis-je définir joliment définir les colonnes afin que chaque article s'adapte bien sous la tête? P>

Voici mon recyclageView: p>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:gravity="center">

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        app:cardBackgroundColor="@color/white"
        app:cardCornerRadius="15dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dp"
                android:layout_marginBottom="25dp"
                android:orientation="vertical">


                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="20dp"
                        android:text="Bestellübersicht"
                        android:textAlignment="center"
                        android:textSize="25dp"
                        android:textStyle="bold"></TextView>

                    <TextView
                        android:id="@+id/order_overview_number"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="20dp"
                        android:text="0"
                        android:textAlignment="center"
                        android:textSize="25dp"
                        android:textStyle="bold" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_marginTop="10dp"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="20dp"
                        android:layout_marginRight="10dp"
                        android:text="Produkt"
                        android:textAlignment="center"
                        android:textSize="18dp"
                        android:textStyle="bold">

                    </TextView>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="10dp"
                        android:text="Anzahl"
                        android:textAlignment="center"
                        android:textSize="18dp"
                        android:textStyle="bold">

                    </TextView>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="10dp"
                        android:text="Preis"
                        android:textAlignment="center"
                        android:textSize="18dp"
                        android:textStyle="bold">

                    </TextView>

                </LinearLayout>

                <androidx.coordinatorlayout.widget.CoordinatorLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">

                    <androidx.core.widget.NestedScrollView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:clipToPadding="true"
                        app:layout_behavior="@string/appbar_scrolling_view_behavior">

                        <androidx.recyclerview.widget.RecyclerView
                            android:id="@+id/recyclerview_order_scroll"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">

                        </androidx.recyclerview.widget.RecyclerView>
                    </androidx.core.widget.NestedScrollView>


                </androidx.coordinatorlayout.widget.CoordinatorLayout>

                <com.airbnb.lottie.LottieAnimationView
                    android:layout_width="match_parent"
                    android:layout_height="128dp"
                    app:lottie_autoPlay="true"
                    app:lottie_loop="true"
                    app:lottie_rawRes="@raw/walkingburger" />

                <Button
                    android:id="@+id/btn_order_overview_finish"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="5dp"
                    android:layout_marginRight="10dp"
                    android:background="@drawable/button_order_checkout"
                    android:backgroundTint="#9BC3BF"
                    android:elevation="16dp"
                    android:text="FERTIG"
                    android:textColor="#FFFFFF"
                    android:textStyle="bold"
                    app:layout_constraintVertical_bias="0.777" />


            </LinearLayout>

        </LinearLayout>

    </androidx.cardview.widget.CardView>


</RelativeLayout>


0 commentaires

3 Réponses :


0
votes

Tout d'abord, dans votre pop, pour "Produkt", "anzahl" etc. vous écrivez layout_width comme "match_parent", mais dans votre recyclerview Layout_Width des articles est Wrap_Content. Changer layout_width sur match_Parent dans votre RecyclerVoir.


0 commentaires

0
votes

Vous avez besoin d'une mise en page de la vue de table afin d'aligner les textes, vous pouvez également utiliser une disposition linéaire, mais une solution d'interface utilisateur complexe et complexe qui effectue des opérations assez lourdes sur la couche d'interface utilisateur afin de rendre (exemple en utilisant des poids dans la disposition linéaire). Vérifiez cet officiel Android lien pour plus de compréhension.


0 commentaires

0
votes

Vous devez utiliser un modèle de mise en page similaire pour la mise en page de titre et l'élément de la vue Recycler. C'est

Utiliser p>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center">

<androidx.cardview.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    app:cardBackgroundColor="@color/white"
    app:cardCornerRadius="15dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="25dp"
            android:layout_marginBottom="25dp"
            android:orientation="vertical">


            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="20dp"
                    android:text="Bestellübersicht"
                    android:textAlignment="center"
                    android:textSize="25dp"
                    android:textStyle="bold"></TextView>

                <TextView
                    android:id="@+id/order_overview_number"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="20dp"
                    android:text="0"
                    android:textAlignment="center"
                    android:textSize="25dp"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"
                android:weightSum="3"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:layout_marginRight="10dp"
                    android:text="Produkt"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:textAlignment="center"
                    android:textSize="18dp"
                    android:textStyle="bold">

                </TextView>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="10dp"
                    android:text="Anzahl"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:textAlignment="center"
                    android:textSize="18dp"
                    android:textStyle="bold">

                </TextView>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="10dp"
                    android:text="Preis"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:textAlignment="center"
                    android:textSize="18dp"
                    android:textStyle="bold">

                </TextView>

            </LinearLayout>

            <androidx.coordinatorlayout.widget.CoordinatorLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <androidx.core.widget.NestedScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:clipToPadding="true"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior">

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/recyclerview_order_scroll"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                    </androidx.recyclerview.widget.RecyclerView>
                </androidx.core.widget.NestedScrollView>


            </androidx.coordinatorlayout.widget.CoordinatorLayout>

            <com.airbnb.lottie.LottieAnimationView
                android:layout_width="match_parent"
                android:layout_height="128dp"
                app:lottie_autoPlay="true"
                app:lottie_loop="true"
                app:lottie_rawRes="@raw/walkingburger" />

            <Button
                android:id="@+id/btn_order_overview_finish"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="5dp"
                android:layout_marginRight="10dp"
                android:background="@drawable/button_order_checkout"
                android:backgroundTint="#9BC3BF"
                android:elevation="16dp"
                android:text="FERTIG"
                android:textColor="#FFFFFF"
                android:textStyle="bold"
                app:layout_constraintVertical_bias="0.777" />


        </LinearLayout>

    </LinearLayout>

</androidx.cardview.widget.CardView>


</RelativeLayout>


2 commentaires

Merci beaucoup! :) Je te souhaite le meilleur. Beaucoup d'argent et de toute la santé des mondes! :)


Joyeux codage! Je vous souhaite la même. :)