Мне никогда не удавалось понять, как правильно настроить ограничение просмотра в нижней части, если любое другое представление находится выше представления recycle. Там должно быть что-то тривиальное, что я упускаю, потому что это довольно сводит с ума.
Следующий макет выглядит хорошо:
<?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/colorWhite"
tools:context=".alerts.AlertsActivity">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/alerts_swiperefresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/alerts_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/md_keylines"
android:paddingTop="@dimen/md_keylines"
android:paddingRight="@dimen/md_keylines" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Теперь давайте добавим View с фиксированной высотой над recycleview.
<?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/colorWhite"
tools:context=".alerts.AlertsActivity">
<View
android:id="@+id/top"
android:layout_width="0dp"
android:layout_height="80dp"
android:background="#20000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/alerts_swiperefresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/top">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/alerts_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/md_keylines"
android:paddingTop="@dimen/md_keylines"
android:paddingRight="@dimen/md_keylines" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Теперь вид переработчика больше не ограничен должным образом в нижней части, а нижний элемент не виден или частично отрезан. Дизайнер также указывает, что нижняя часть окна рециркуляции находится за пределами экрана.
Если я заменим Constraintlayout на RelativeLayout или LinearLayout, он будет выглядеть просто отлично.
Разница легко визуализируется с точки зрения дизайнера.
