В моем ConstraintLayout
у меня есть RecyclerView
внутри SwipeRefreshLayout
и CardView
, который расположен ниже SwipeRefreshLayout
, как показано ниже:
<?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"
android:animateLayoutChanges="true"
android:background="@color/backgroundPrescriptionFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/srlActivePrescription"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintVertical_weight="100"
app:layout_constraintBottom_toTopOf="@id/cvRequestRefills"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvActivePrescription"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="16dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivNoActivePresc"
android:layout_width="@dimen/prescription_empty_view"
android:layout_height="@dimen/prescription_empty_view"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/tvNoActivePresc"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
/>
<TextView
android:id="@+id/tvNoActivePresc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:text="@string/text_no_active_prescription"
android:textAlignment="center"
android:textColor="@color/dark_gray"
android:textSize="20sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivNoActivePresc" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/cvRequestRefills"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:cardElevation="4dp"
android:visibility="gone"
app:cardBackgroundColor="@color/colorPrimary"
app:cardCornerRadius="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvDrugSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:text="@string/text_drug_selected"
android:textColor="@android:color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@string/text_request_refills"
android:textColor="@android:color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@+id/ivRequestRefills"
app:layout_constraintEnd_toStartOf="@+id/ivRequestRefills"
app:layout_constraintTop_toTopOf="@+id/ivRequestRefills" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ivRequestRefills"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="16dp"
android:tint="@android:color/white"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_arrow_forward"
tools:ignore="KeyboardInaccessibleWidget"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
Исходя из определенных условий, я должен показать CardView, который должен появиться в нижней части экрана, но проблема в том, что когда видимость CardView установлена на Visible, он отображается немного ниже экрана, и у меня есть прокрутите немного, чтобы увидеть CardView.
Кроме того, при прокрутке вниз CardView скрывается и возвращается при прокрутке вверх. Я хочу, чтобы CardView всегда оставался видимым и находился в фиксированном положении внизу.