Как я могу адаптировать размер ресивера в соответствии с детьми, показанными в этом - PullRequest
0 голосов
/ 27 апреля 2020

Я хочу показать представление reclycer, но оно адаптируется к росту дочерних элементов, потому что есть другие элементы ниже представления reclycer. Когда представление reclycer настроено с высотой «match_parent», оно показывает количество дочерних элементов в нем, но оно занимает весь экран, и идея такова: при наличии дочерних элементов представление reclycler будет загружаться на экран

Затем я оставляю свой макет

<RelativeLayout
    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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Cesta_Activity">


    <TextView
        android:id="@+id/Mis_Pedidos"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/Cesta"
        android:text="Mis Pedidos"
        android:textSize="18dp"
        android:textStyle="bold"
        android:textColor="@android:color/white"
        android:background="@color/Letra"
        android:padding="16dp"
        android:gravity="center"
        android:drawableLeft="@drawable/ic_cesta_mas"
        android:drawablePadding="25dp"
        />
    <TextView
        android:id="@+id/Nombre_Restaurante"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Restaurante"
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"
        android:visibility="invisible"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_below="@+id/Mis_Pedidos">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/Reclycer_Cesta"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Mis_Pedidos"
        />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

        <Button
            android:id="@+id/Btn_Ordenar"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:layout_below="@+id/Edt_Observación"
            android:layout_marginRight="105dp"
            android:layout_marginLeft="105dp"
            android:background="@drawable/boton_redondeado"
            android:text="añadir a la cesta"
            android:textColor="@android:color/white"
            android:textSize="16dp"
            android:textStyle="bold"
            />
    </RelativeLayout>

    </LinearLayout>
</RelativeLayout>

С этим кодом ничего не отображается внутри reclyclerview

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...