How can i constraint the recyclerview elements to the fragment itself, i made a recyclerview with 3 textviews, then I made item list fragment to contain a labels and the recyclerview but when i open the app i get like the screenshot shows.
i want the recyclerview to be in match line with the Item, Price and quantity labels
RecyclerView
<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="48dp"
android:descendantFocusability="blocksDescendants">
<TextView
android:id="#+id/item_name"
style="#style/Widget.Inventory.ListItemTextView"
android:layout_width="180dp"
android:layout_marginStart="#dimen/margin_between_elements"
android:fontFamily="sans-serif"
app:layout_constraintEnd_toStartOf="#+id/item_price"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Cogs and Widgets" />
<TextView
android:id="#+id/item_price"
style="#style/Widget.Inventory.ListItemTextView"
android:layout_width="100dp"
android:layout_below="#+id/item_name"
android:layout_marginStart="#dimen/margin_between_elements"
android:fontFamily="sans-serif-medium"
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="#+id/item_quantity"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="#+id/item_name"
app:layout_constraintTop_toTopOf="parent"
tools:text="$4.99" />
<TextView
android:id="#+id/item_quantity"
style="#style/Widget.Inventory.ListItemTextView"
android:layout_width="80dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="#dimen/margin_between_elements"
android:fontFamily="sans-serif-medium"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintTop_toTopOf="parent"
tools:text="3" />
Fragment
<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"
android:layout_margin="#dimen/margin"
tools:context=".ItemListFragment">
<TextView
android:id="#+id/item_name"
style="#style/Widget.Inventory.Header"
android:layout_marginStart="#dimen/margin_between_elements"
android:text="#string/item"
app:layout_constraintEnd_toStartOf="#+id/item_price"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/item_price"
style="#style/Widget.Inventory.Header"
android:layout_below="#+id/item_name"
android:layout_marginStart="#dimen/margin_between_elements"
android:text="#string/price"
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="#+id/item_quantity"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="#+id/item_name"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/item_quantity"
style="#style/Widget.Inventory.Header"
android:layout_alignParentEnd="true"
android:layout_marginEnd="#dimen/margin_between_elements"
android:text="#string/quantity_in_stock"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="#+id/item_price"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="#+id/divider"
style="#style/Divider"
android:layout_marginTop="#dimen/margin_between_elements"
app:layout_constraintBottom_toTopOf="#+id/recyclerView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/item_quantity" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/divider" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/margin_between_elements"
android:layout_marginBottom="#dimen/margin_between_elements"
android:contentDescription="#string/add_new_item"
android:src="#android:drawable/ic_input_add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:tint="#android:color/white" />
</androidx.constraintlayout.widget.ConstraintLayout>
Related
I currently have a recyclerview that goes vertically on the page, but I need additional data for each element in that recyclerview to be represented on the page by scrolling horizontally as well. The attached image displays what I currently have, and diagrams what I need.See image
The following are the 2 xml files in charge of creating that display.
<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=".Team_Yearly_Stats">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="1dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="#+id/recyclerView"
app:layout_constraintEnd_toEndOf="#+id/recyclerView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/recyclerView" />
<TextView
android:id="#+id/wait"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Please Wait"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/progressBar" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="W"
app:layout_constraintBottom_toTopOf="#+id/recyclerView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.181"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="19dp"
android:text="L"
app:layout_constraintBottom_toTopOf="#+id/recyclerView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
<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="wrap_content"
android:layout_marginTop="0dp"
android:backgroundTint="?attr/colorButtonNormal"
android:padding="5dp">
<androidx.cardview.widget.CardView
android:layout_width="409dp"
android:layout_height="wrap_content"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<TextView
android:id="#+id/wins"
android:layout_width="57dp"
android:layout_height="36dp"
android:layout_marginStart="-40dp"
android:layout_marginTop="8dp"
android:text="Sample Title"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.331"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/loses"
android:layout_width="113dp"
android:layout_height="30dp"
android:layout_marginTop="12dp"
android:text="Sample Title"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/wins"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/desc"
android:layout_width="53dp"
android:layout_height="32dp"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:text="Sample Description for the given title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/wins"
app:layout_constraintHorizontal_bias="0.04"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.06" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Yes you can there are various libraries like https://github.com/evrencoskun/TableView but there are various sizing issues with this one.
Or shameless plug https://github.com/Zardozz/FixedHeaderTableLayout though this is not a recycler View but it does not have the sizing issues that come with a recycler based view and it offers zooming (not available on recycler based views).
I'm trying to implement a proper snackbar that doesn't overlap other views, to do that I added to the activity a Coordinator Layout and inside I placed a constraint layout with the views I want to be pushed up. In the constraint layout I set the attribute app:layout_dodgeInsetEdges="bottom" but when the snackbar appears it pushes the views upwards but it is a little glitchy, here is the video:
video
The video is of an emulator but the same thing happens on real phones.
<?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=".login.LoginActivity">
<ImageView
android:id="#+id/login_logo"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_marginStart="80dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="80dp"
android:contentDescription="#string/logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/google_logo" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/loginCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_outwire_logo">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/innerConstraintlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_dodgeInsetEdges="bottom">
<LinearLayout
android:id="#+id/create_account_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/facebook_sign_button">
<TextView
android:id="#+id/dont_have_account_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:text="#string/don_t_have_an_account"
android:textSize="#dimen/subTextSize" />
<TextView
android:id="#+id/create_account_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:text="#string/create_account"
android:textColor="#color/clickable_subtext_blue"
android:textSize="#dimen/subTextSize" />
</LinearLayout>
<EditText
android:id="#+id/login_user_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:autofillHints="Username, Email"
android:ems="14"
android:hint="#string/email_username"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="TextFields" />
<EditText
android:id="#+id/login_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autofillHints="Password"
android:ems="14"
android:hint="#string/password"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_user_email" />
<com.app.custom.views.SignInButton
android:id="#+id/sign_in_button"
android:layout_width="#dimen/sign_button_width"
android:layout_height="#dimen/sign_button_height"
android:layout_marginTop="48dp"
android:background="#drawable/sign_in_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_password"
app:text="#string/sign_in"
app:text_color="?attr/colorOnPrimary"
app:text_size="#dimen/sign_button_text" />
<TextView
android:id="#+id/forgot_password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:clickable="true"
android:elevation="2dp"
android:focusable="true"
android:text="#string/forgot_your_password"
android:textColor="#color/clickable_subtext_blue"
android:textSize="#dimen/subTextSize"
app:layout_constraintEnd_toEndOf="#+id/login_password"
app:layout_constraintTop_toBottomOf="#+id/login_password" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/or_sign_in_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.6"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="#+id/google_sign_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/sign_in_button">
<View
android:id="#+id/separator"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/separator_grey"
android:contentDescription="#string/sign_in_options_separator"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/or_sign_in_with_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/or_sign_in_with_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/or_sign_in_with"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="#+id/separator2"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/separator_grey"
android:contentDescription="#string/sign_in_options_separator"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/or_sign_in_with_text"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.app.custom.views.SignInButton
android:id="#+id/google_sign_button"
android:layout_width="#dimen/sign_button_width"
android:layout_height="#dimen/sign_button_height"
android:layout_marginTop="64dp"
android:backgroundTint="?attr/colorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/sign_in_button"
app:src_logo="#drawable/google_logo"
app:text="#string/google"
app:text_color="?attr/colorOnSecondary" />
<com.app.custom.views.SignInButton
android:id="#+id/facebook_sign_button"
android:layout_width="#dimen/sign_button_width"
android:layout_height="#dimen/sign_button_height"
android:layout_marginTop="8dp"
android:backgroundTint="#color/facebook_blue"
android:clickable="true"
android:focusable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/google_sign_button"
app:src_logo="#drawable/fb_logo"
app:text="#string/facebook"
app:text_size="#dimen/sign_button_text"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
I need to show() the extended FAB and hide() it based on a boolean. I'm using it in a bottom sheet that extends BottomSheetDialogFragment. Problem is that it works when the bottom sheet is in expanded state, but not in the state in which the sheet opens by default. I also observe a strange behavior - the FAB shows by default when the sheet opens, for a fleeting second and disappears. I'm not sure what's causing this behavior. I tried hiding the FAB by default, but it does not work.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.core.widget.NestedScrollView
android:layout_gravity="top"
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:context=".ui.attendance.employee.selection.EmployeeSelectionBottomSheet">
<TextView
android:id="#+id/copy_to_emp_title"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:paddingBottom="16dp"
android:text="#string/copy_to"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:background="#color/palegrey"
android:id="#+id/copy_to_emp_search_cc"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:paddingBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/copy_to_emp_title"
tools:visibility="visible">
<com.google.android.material.textfield.TextInputLayout
style="#style/TextInputLayoutAppearance"
android:hint="#string/enter_chip_txt"
android:id="#+id/copy_to_emp_search_til"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_width="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<HorizontalScrollView
android:id="#+id/copy_to_emp_hsv"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scrollbars="none">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="503dp">
<com.google.android.material.chip.ChipGroup
android:id="#+id/copy_to_emp_cg"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_constraintBottom_toBottomOf="#+id/copy_to_emp_et"
app:layout_constraintEnd_toStartOf="#+id/copy_to_emp_et"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/copy_to_emp_et" />
<com.google.android.material.textfield.TextInputEditText
android:hint="#string/enter_chip_txt"
android:id="#+id/copy_to_emp_et"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/copy_to_emp_cg"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</HorizontalScrollView>
</com.google.android.material.textfield.TextInputLayout>
<TextView
style="#style/Body14Left4SemiBold"
android:id="#+id/copy_to_emp_filter"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="#string/filter"
app:layout_constraintBottom_toBottomOf="#+id/copy_to_emp_filter_icon"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toTopOf="#+id/copy_to_emp_filter_icon" />
<ImageView
android:id="#+id/copy_to_emp_filter_icon"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:padding="3dp"
android:src="#{isFilterViewExpanded?#drawable/ic_arrow_up:#drawable/ic_arrow_down}"
app:layout_constraintEnd_toEndOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_search_til"
tools:src="#drawable/ic_arrow_down" />
<TextView
style="#style/Body14Left2Regular"
android:id="#+id/copy_to_emp_category_label"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:text="#string/category"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_filter" />
<TextView
style="#style/Body14Left2Regular"
android:background="#drawable/rounded_rect_white_5"
android:id="#+id/copy_to_emp_category"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="8dp"
android:layout_width="0dp"
android:padding="8dp"
android:text="#string/select_your_filter_category"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_category_label" />
<TextView
style="#style/Body14Left2Regular"
android:id="#+id/copy_to_emp_sub_category_label"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:text="#string/sub_category"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_category" />
<TextView
style="#style/Body14Left2Regular"
android:background="#drawable/rounded_rect_white_5"
android:id="#+id/copy_to_emp_sub_category"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:layout_width="0dp"
android:padding="8dp"
android:text="#string/select_your_filter_sub_category"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/copy_to_emp_search_til"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_sub_category_label" />
<com.google.android.material.button.MaterialButton
android:id="#+id/copy_to_add_filter_btn"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="wrap_content"
android:text="Add Filter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/copy_to_emp_sub_category" />
<androidx.constraintlayout.widget.Group
android:id="#+id/copy_to_emp_group"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="#{isFilterViewExpanded?View.VISIBLE:View.GONE}"
app:constraint_referenced_ids="copy_to_emp_sub_category,copy_to_emp_sub_category_label,copy_to_emp_category,copy_to_emp_category_label, copy_to_add_filter_btn"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.chip.ChipGroup
android:id="#+id/copy_to_selected_filter_cg"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_width="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/copy_to_emp_search_cc" />
<TextView
android:id="#+id/copy_to_emp_count_tv"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_width="wrap_content"
android:text="All Employee (264)"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/copy_to_selected_filter_cg" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/copy_to_rv"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:minHeight="60dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/copy_to_emp_count_tv" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:backgroundTint="#color/blueberry"
android:id="#+id/copy_to_apply_changes_btn"
android:layout_gravity="bottom|center_horizontal"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_width="wrap_content"
android:text="Apply changes"
android:textColor="#color/whitetwo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
change ExtendedFloatingActionButton to FloatingActionButton
Add
<com.google.android.material.circularreveal.CircularRevealFrameLayout
/>
</com.google.android.material.circularreveal.CircularRevealFrameLayout>
fab.setOnClickListener {
fab.isExpanded = !fab.isExpanded
}
thats it
I have two layouts with ConstraintLayout which has a child NestedScrollview and NestedScrollview have a child ConstraintLayout again as a container than other views. I want animate both layouts using ConstraintSet but unfortunately, this is not working. On other hands, if I remove NestedScrollview and root ConstraintLayout then it works fine. I want to achieve this task with NestedScrollview or Scroll view is this possible? Thanks in advance.
Here is my Code
activity_login.xml
<?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:id="#+id/root_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:isScrollContainer="true"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<!-- Login progress -->
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="8dp">
<!-- Login progress -->
<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:id="#+id/root_lay_la"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<ImageView
android:id="#+id/iv_login_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/nature" />
<ProgressBar
android:id="#+id/pb_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tv_login_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="#dimen/fab_margin"
android:paddingTop="#dimen/small_padding"
android:paddingEnd="#dimen/fab_margin"
android:paddingBottom="#dimen/small_padding"
android:text="Login Heading"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="#+id/btn_sign_in_la"
android:layout_width="0dp"
android:layout_height="#dimen/button_size"
android:layout_gravity="center_horizontal"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="32dp"
android:layout_marginEnd="#dimen/fab_margin"
android:layout_marginBottom="8dp"
android:background="#drawable/login_btn_back"
android:paddingStart="#dimen/button_padding"
android:paddingTop="#dimen/normal_padding"
android:paddingEnd="#dimen/button_padding"
android:paddingBottom="#dimen/normal_padding"
android:text="#string/sign_in"
android:textAllCaps="false"
android:textColor="#color/primaryDark"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/iv_login_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_password_la"
app:layout_constraintVertical_bias="0.04000002" />
<TextView
android:id="#+id/tv_heading_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:paddingStart="#dimen/big_margin"
android:paddingEnd="#dimen/big_margin"
android:text="Login with Saini Communication and get more offers!"
android:textColor="#color/white"
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="#+id/et_email_or_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_phone_iphone_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/mobile"
android:inputType="phone"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent" />
<EditText
android:id="#+id/et_password_la"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_lock_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/prompt_password"
android:inputType="textPassword"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_email_or_phone" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>
activity_login_detial.xml
<?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:id="#+id/root_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="8dp">
<!-- Login progress -->
<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:id="#+id/root_lay_la"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<ImageView
android:id="#+id/iv_login_back"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.26999998"
app:srcCompat="#drawable/nature" />
<ProgressBar
android:id="#+id/pb_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tv_login_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="#dimen/fab_margin"
android:paddingTop="#dimen/small_padding"
android:paddingEnd="#dimen/fab_margin"
android:paddingBottom="#dimen/small_padding"
android:text="Login Heading"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/btn_sign_in_la"
android:layout_width="0dp"
android:layout_height="#dimen/button_size"
android:layout_gravity="center_horizontal"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="32dp"
android:layout_marginEnd="#dimen/fab_margin"
android:layout_marginBottom="8dp"
android:background="#drawable/login_btn_back"
android:paddingStart="#dimen/button_padding"
android:paddingTop="#dimen/normal_padding"
android:paddingEnd="#dimen/button_padding"
android:paddingBottom="#dimen/normal_padding"
android:text="#string/sign_in"
android:textAllCaps="false"
android:textColor="#color/primaryDark"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/iv_login_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_password_la"
app:layout_constraintVertical_bias="0.04000002" />
<TextView
android:id="#+id/tv_heading_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:paddingStart="#dimen/big_margin"
android:paddingEnd="#dimen/big_margin"
android:text="Login with Saini Communication and get more offers!"
android:textColor="#color/white"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_login_heading" />
<EditText
android:id="#+id/et_email_or_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_phone_iphone_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/mobile"
android:inputType="phone"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_heading_login" />
<EditText
android:id="#+id/et_password_la"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_lock_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/prompt_password"
android:inputType="textPassword"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_email_or_phone" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>
LoginActivity.java
#BindView(R.id.root_lay_la)
ConstraintLayout animLay;
public void show(){
show=true;
ConstraintSet constraintSet=new ConstraintSet();
constraintSet.clone(this,R.layout.activity_login_detail);
android.support.transition.Transition transition=new android.support.transition.ChangeBounds();
AnticipateOvershootInterpolator interpolator=new AnticipateOvershootInterpolator(1.5f);
transition.setInterpolator(interpolator);
transition.setDuration(1500);
android.support.transition.TransitionManager.beginDelayedTransition(animLay,transition);
constraintSet.applyTo(animLay);
}
public void hide(){
show =false;
ConstraintSet constraintSet=new ConstraintSet();
constraintSet.clone(this,R.layout.activity_login);
android.support.transition.Transition transition=new android.support.transition.ChangeBounds();
AnticipateOvershootInterpolator interpolator=new AnticipateOvershootInterpolator(1.5f);
transition.setInterpolator(interpolator);
transition.setDuration(1500);
android.support.transition.TransitionManager.beginDelayedTransition(animLay,transition);
constraintSet.applyTo(animLay);
}
I have problem in the bottom layout where my constraint layout does not fill the scroll view entirely(blank space bellow). This is the image evidence of the problem.
In this case I want the gray background to fill that white space below. I tried match parent in everything but it does not work.
This is my xml file that belongs to the layout I uploaded
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout">
<data>
<variable
name="viewModel"
type="com.repsol.repsolmove.ui.login.LoginViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="#+id/scrolView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView"
android:layout_width="174dp"
android:layout_height="70dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="3dp"
android:src="#drawable/ic_img_logo_repsolmove"
app:layout_constraintBottom_toTopOf="#+id/imageBottomMargin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="#+id/login"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginTop="30dp"
app:errorText="#string/invalid_card_number"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/imageView"
app:titleText="#string/login_title" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="#+id/password"
android:layout_width="0dp"
android:layout_height="105dp"
app:errorText="#string/invalid_password"
app:isPassword="true"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/login"
app:titleText="#string/password_title" />
<TextView
android:id="#+id/newPassword"
style="#style/RepsolText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:fontFamily="#font/repsol_regular"
android:text="#string/new_password"
android:textSize="16dp"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintTop_toBottomOf="#+id/password" />
<Button
android:id="#+id/btnLogin"
android:layout_width="228dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:background="#drawable/shape_rounded_fill_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/login"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/newPassword" />
<Button
android:id="#+id/btnJoin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
android:background="#drawable/shape_rounded_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/join"
android:textAllCaps="false"
android:textColor="#color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/btnNologin"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<Button
android:id="#+id/btnNologin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="32dp"
android:background="#drawable/shape_rounded_no_stroke_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/enter_without_login"
android:textAllCaps="false"
android:textColor="#color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toEndOf="#+id/btnJoin"
app:layout_constraintTop_toBottomOf="#+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/imageBottomMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.30" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/marginStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.10" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/marginEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.90" />
<com.repsol.repsolmove.ui.widgets.RepsolDialog
android:id="#+id/dialog"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="10dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="#+id/loading"
layout="#layout/loading"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Add this attribute to your NestScrollView element in xml file
android:fillViewport="true"