The issue is the background of my scrollview is somewhat have pretty same content as my scroll view. i have try looking but can't found the problem, because every place tell that i just have to place the content into the scrollview. Please Help!
The design of the layout
This is my layout code
<?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=".ui.home.HomeFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/category_rv"
android:layout_width="match_parent"
android:background="#color/colorAccent"
android:elevation="3dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/category_rv">
<include layout="#layout/horizontal_scroll_layout" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/LinearLayout">
<include layout="#layout/sliding_ad_layout" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/LinearLayout1">
<include layout="#layout/grid_product_layout" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Put recyclerview and scrollview into nestedscrollview
This will solve your problem.
Add constraints to your scroll view, not to LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/category_rv">
Related
Inside this
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:background="#color/backgroundColor"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="12dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
I have this
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/banner_rl"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="330:128"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.9">
<ImageView ... />
<TextView ... />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
Unless I insert that outermost RelativeLayout, the ConstraintLayout would not wrap the Image. it would be 0dp instead of the content's.
Why is that? Why does the CL need to be wrapped by a RL to identify it's contents?
I am trying to create a square LinearLayout container of id imgContainer within a ScrollView element, but I am unable to do so because the app:layout_constraintDimensionRatio doesn't seem to be working. Using the following xml code, the imgContainer renders with a height of 0dp:
<?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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/imgContainer"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/trackName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_weight="1"
android:text="Test Name"
android:textSize="25dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imgContainer" />
<!-- Other stuff -->
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
However, when I move the imgContainer out of the ScrollView like so, the imgContainer is square-shaped as expected.
<?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">
<LinearLayout
android:id="#+id/imgContainer"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
...>
<!-- Same as above -->
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
I also tried moving out of the LinearLayout it is nested in while still having it within the ScrollView, but that didn't work either. If anyone knows how to fix this, and why this happens, that would be great. Thanks in advance.
app:layout_constraint.. only work under <androidx.constraintlayout.widget.ConstraintLayout
you can try the following:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/imgContainer"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/trackName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_weight="1"
android:text="Test Name"
android:textSize="25dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imgContainer" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I tried to make the title as descriptive as possible.
I have a ConstraintLayout with two LinearLayout children that have ScrollViews inside as there are a lot of stuff inside. Each child has a weight of 1. The layout has constraints to top of toolbar, bottom, left and right to parent and a margin to top. So basically, this layout acts as a bottom sheet that slides up and down.
Both sub-views (LinearLayouts-s) can be "expanded", in which case, the other sub-view changes its visibility to gone.
So what happens is when I expand one layout and hide another, for some reason, the whole layout's alignment stays to top of the parent, preserving the margin, but gets cut to the bottom, leaving an empty space. I want it to move to the bottom of the screen is such case. I have also added app:layout_constraintVertical_bias="1.0", which I thought would take care of it. But it does not work. I will attach pictures.
So what I am trying to achieve is to make the sheet to get aligned bottom all the time. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar">
<include layout="#layout/merge_screen_container" />
</FrameLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/dim_56x"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar"
app:layout_constraintVertical_bias="1.0" />
</android.support.constraint.ConstraintLayout>
This should work. Please try.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar">
<include layout="#layout/merge_screen_container" />
</FrameLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar"
app:layout_constraintVertical_bias="1.0" >
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/dim_56x"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="#+id/content"
android:layout_width="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar">
<include layout="#layout/merge_screen_container" />
</FrameLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/dim_56x"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbar" />
</android.support.constraint.ConstraintLayout>
So, the answer from #Arti Patel kinda worked, but the filter view would still go beyond toolbar. I ended up using LinearLayout and FrameLayout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?ord_canvas_secondary_color"
android:orientation="vertical">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<include layout="#layout/merge_screen_container" />
</LinearLayout>
<View
android:id="#+id/dim_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="#color/ord_black"
android:clickable="true"
android:focusable="true"
android:visibility="gone" />
<FilterSheet
android:id="#+id/subscriptions_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="#dimen/dim_8x"
android:layout_marginTop="#dimen/filter_margin_top"
android:layout_marginEnd="#dimen/dim_8x"
android:layout_marginBottom="#dimen/dim_8x"
android:visibility="invisible" />
</FrameLayout>
I need to achieve the following view
I tried using constraint layout:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="#id/segmentedButton">
</FrameLayout>
<Buttons
android:id="#+id/segmentedButton"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
</Buttons>
</android.support.constraint.ConstraintLayout>
It works well when there are many items, but when there are just 2-3, it shows them in the middle.
Also, I tried using LinearLayout but no luck.
you can use RelativeLayouttoo to get your desired results. By using the below code you can show the items on top if they are 2 or 3 left.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/segmentedButton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<Button
android:id="#+id/segmentedButton"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
try with linear layout, weight property should push the button to align at the end of parent
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_weight="1"
>
</FrameLayout>
<Buttons
android:id="#+id/segmentedButton"
android:layout_width="wrap_content"
android:layout_height="50dp"
>
</Buttons>
</LinearLayout>
I supposed here that Buttons stand for a custom Button you made
Just add Top Constraint to your FrameLayout, should fix your issue.
Your final layout will be like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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">
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/segmentedButton"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"></FrameLayout>
<Buttons
android:id="#+id/segmentedButton"
android:layout_width="0dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"></Buttons>
</android.support.constraint.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">
<FrameLayout
android:id="#+id/segmentedFrame"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#+id/segmentedButton"
android:background="#drawable/bg_scan_edittext">
</FrameLayout>
<Button
android:id="#+id/segmentedButton"
android:layout_width="wrap_content"
android:layout_height="50dp"
app:layout_constraintTop_toBottomOf="#+id/segmentedFrame"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
</Button>
</android.support.constraint.ConstraintLayout>
I'm trying to create a bottom sheet dialog based on a complex layout.
What I have to achieve is a dialog with an header layout, a recycler view with a list of element and a bottom bar with a couple of buttons.
Here is my code:
<?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">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Layout injected inside this linear layout container programmatically -->
<LinearLayout
android:id="#+id/header_dialog_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#id/form_dialog_recycler_view"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.RecyclerView
android:id="#+id/form_dialog_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toTopOf="#id/bottom_sheet_container_buttons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/header_dialog_container" />
<LinearLayout
android:id="#+id/bottom_sheet_container_buttons"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
<Button
android:id="#+id/dialog_sheet_button_reset"
style="#style/ActionSheetTitle"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="0.5"
android:background="#color/bottomBarContainerColor"
android:text="#string/general_reset"
android:textColor="#color/dangerColor" />
<Button
android:id="#+id/dialog_sheet_button_close"
style="#style/ActionSheetTitle"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="0.5"
android:background="#color/bottomBarContainerColor"
android:text="#string/general_close" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</layout>
Unfortunately my recycler view height is always equal to zero. I tried to change android:layout_height="0dp" to android:layout_height="wrap_content" but as expected it goes below the bottom container. Am I missing something?
Try app:layout_constraintHeight_default="wrap" for RecyclerView if it's inside ConstraintLayout.
I ended up with a different solution. I changed constraint layout with a Linear Layout. And I set up bottom margins.
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/header_dialog_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<android.support.v7.widget.RecyclerView
android:id="#+id/form_dialog_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="60dp"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<LinearLayout
android:id="#+id/bottom_sheet_container_buttons"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="-60dp"
android:orientation="horizontal">
<Button
android:id="#+id/dialog_sheet_button_reset"
style="#style/ActionSheetTitle"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="0.5"
android:background="#color/bottomBarContainerColor"
android:text="#string/general_reset"
android:textColor="#color/dangerColor" />
<Button
android:id="#+id/dialog_sheet_button_close"
style="#style/ActionSheetTitle"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="0.5"
android:background="#color/bottomBarContainerColor"
android:text="#string/general_close" />
</LinearLayout>
</LinearLayout>
</layout>
Try this code:
<?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">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Layout injected inside this linear layout container programmatically -->
<LinearLayout
android:id="#+id/header_dialog_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#id/form_dialog_recycler_view"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.RecyclerView
android:id="#+id/form_dialog_recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toTopOf="#id/bottom_sheet_container_buttons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/header_dialog_container" />
<LinearLayout
android:id="#+id/bottom_sheet_container_buttons"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent">
<Button
android:id="#+id/dialog_sheet_button_reset"
style="#style/ActionSheetTitle"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="0.5"
android:background="#color/bottomBarContainerColor"
android:text="#string/general_reset"
android:textColor="#color/dangerColor" />
<Button
android:id="#+id/dialog_sheet_button_close"
style="#style/ActionSheetTitle"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="0.5"
android:background="#color/bottomBarContainerColor"
android:text="#string/general_close" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</layout>
Use app:layout_constrainedHeight="true" in your RecyclerView. It will adjust inside constraints and won't go below the bottom container.