(android) how to place a view below other views in constraint layout


goodbye

enter image description here

This picture is the statuslayout

I want to put RecyclerViewthe followingButton

However, as you can see, even when used layout_constraintTop_toBottomOf, RecyclerViewit doesn't place

underButton

There is a condition that RecyclerViewmust be the size math_parent.

This is because you are using nesting recycler viewand you are adding items dynamically, otherwise

recycler view's itemWhen added dynamically , the last nest will be cut off and not visible.

If I set the height of the view to match_parent in constraint layout, is there any way to place it

Other comments below?

This is the XML file.

activity_write_routine.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".data.DailyRecordDetailActivity">
    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/Theme.AppBarOverlay"
        app:elevation="0dp">
        <androidx.appcompat.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <TextView
                    android:id="@+id/body_part_detail_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="P A R T"
                    android:textColor="@color/white"
                    android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
                    android:layout_centerHorizontal="true"/>
            </RelativeLayout>
        </androidx.appcompat.widget.Toolbar>
    </com.google.android.material.appbar.AppBarLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
        <Button
            android:id="@+id/add_routine"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="A D D"
            android:backgroundTint="@color/light_green"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintRight_toRightOf="parent"/>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/routine_recyclerview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical"
            app:layout_constraintTop_toBottomOf="@+id/add_routine"/>
    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Rilawela Bay

Change the height to 0dp and constrain the bottom of the recyclerview to parent

<androidx.recyclerview.widget.RecyclerView
      android:id="@+id/routine_recyclerview"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:scrollbars="vertical"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/add_routine"/>

Related


Can't place text view below guideline using constraint layout

Cusalia I am trying to place a TextView below the guide. I have tried as follows, <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:

Android scroll view overlapping other views below

kushurox TW I recently started learning Android development and wanted to make an app that adds messages as you enter text in an EditText widget. At the top of my activity is a scroll view and below it is an EditText view and a button for sending a message. He

Android scroll view overlapping other views below

kushurox TW I recently started learning Android development and wanted to make an app that adds messages as you enter text in an EditText widget. At the top of my activity is a scroll view and below it is an EditText view and a button for sending a message. He

Android scroll view overlapping other views below

kushurox TW I recently started learning Android development and wanted to make an app that adds messages as you enter text in an EditText widget. At the top of my activity is a scroll view and below it is an EditText view and a button for sending a message. He

Android constraint layout positioning 1 item below other

MA 2340 I have a constraint layout and the layout looks like this - As you can see the items Pastaare 10:10aligned one below the other. My layout is like this - <?xml version="1.0" encoding="utf-8"?> <com.google.android.material.card.MaterialCardView xmlns:and

How can I place a view below other animations?

Shermano I started learning animations on android today, but I can't position the view after the animation is over. When the app starts, it shows a search EditText in the center of the screen, when you search for something, this EditText should slide to the to

Android XML: How to place widgets below the contained layout

Adam Lee I'm trying to put a chart widget (com.android.AnyChartView, @+id/piechart ) from the AnyChart library ( https://github.com/AnyChart/AnyChart-Android ) in an included layout ( @layout/content_main ) Contains one below . I tried giving an id and setting

Android XML: How to place widgets below the contained layout

Adam Lee I'm trying to put a chart widget (com.android.AnyChartView, @+id/piechart ) from the AnyChart library ( https://github.com/AnyChart/AnyChart-Android ) in an included layout ( @layout/content_main ) Contains one below . I tried giving an id and setting

Constraint layout - place Viewpager above another view

flagellum I'm trying to place a Viewpager on top of another view in a constraint layout, but unless I use a set height (eg "150dp"), the Viewpager stretches all the way to the bottom of the parent. How would I make it so that it only expands to the top of the

Constraint layout - place Viewpager above another view

flagellum I'm trying to place a Viewpager on top of another view in a constraint layout, but unless I use a set height (eg "150dp"), the Viewpager stretches all the way to the bottom of the parent. How would I make it so that it only expands to the top of the