Я изо всех сил пытаюсь найти решение этой проблемы.
В принципе, у меня есть макет с заголовком и нижним колонтитулом.Мне нужно поместить 1 ListView и 2 View внутри оставшегося пространства, чтобы:
- ListView начинался сверху и заполнял все доступное пространство
- View1 сразу после ListView
- View2 находится сразу после View1
- , если ListView не виден (или очень короткий), представления должны отображаться в верхней части экрана.
- ListView должен расширяться до screen_heigth -header -footer-view1 -view2
Я пробовал каждую возможную комбинацию цепочек, помещая представления в linearLayouts, используя только ограничения и смещения, но самое близкое, что я получил, - это упакованные представления в правильном порядке, но вместо этого по центрув верхней части экрана.
<?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">
<View
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"/>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/view1"
app:layout_constraintTop_toBottomOf="@+id/header"
app:layout_constraintVertical_chainStyle="packed" />
<View
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/view2"
app:layout_constraintTop_toBottomOf="@+id/list_view" />
<View
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/footer"
app:layout_constraintTop_toBottomOf="@+id/view1"/>
<View
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>
Кто-нибудь может мне помочь с этим?Я также могу при необходимости поменять constraintLayout на что-то другое