0

Как сделать чтобы после RecyclerView отображался LinearLayout

<androidx.recyclerview.widget.RecyclerView

    android:id="@+id/recyclerView_recountData_id"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintTop_toBottomOf="@+id/recyclerView_Porods_id">

</androidx.recyclerview.widget.RecyclerView>

<LinearLayout
    android:id="@+id/test"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/buttonId_addStepToWood"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:text="+" />
    <Button
        android:id="@+id/buttonId_delStepToWood"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.5"
        android:text="-" />
</LinearLayout>

введите сюда описание изображения

1
  • это весь код разметки? выглядит как два независимых элемента
    – Andrew
    16 апр 2021 в 11:55

1 ответ 1

2

Максимально непонятно какой родительский элемент и у вас на скриншоте два списка а в вопросе упоминается только один. Если вы планируете использовать androidx.constraintlayout.widget.ConstraintLayout то можно сделать так:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity">

    <androidx.recyclerview.widget.RecyclerView

        android:id="@+id/recyclerView_Porods_id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/holo_orange_light"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView_recountData_id"
        android:layout_width="match_parent"
        android:background="@android:color/holo_purple"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/recyclerView_Porods_id">

    </androidx.recyclerview.widget.RecyclerView>

    <LinearLayout
        android:id="@+id/test"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        app:layout_constraintTop_toBottomOf="@+id/recyclerView_recountData_id"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/buttonId_addStepToWood"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="+" />
        
        <Button
            android:id="@+id/buttonId_delStepToWood"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="-" />
    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

вот результат:

введите сюда описание изображения

я добавил цвета чтобы более понятно где какой список находится. Так же можно использовать и простой LinearLayout с вертикальной ориентацией. Тэг который вам вообще был нужен этот:

app:layout_constraintTop_toBottomOf="@+id/recyclerView_recountData_id"

если простыми словами то вы верх элемента с этим тэгом выравниваете по отношению к элементу с указанным id

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.