У меня есть макет с двумя представлениями, который должен вести себя так:
- Сверху находится текст редактирования, который должен динамически расти (и уменьшаться).
Прямо под ним другой взгляд. EditText растет, пока другой
Вид достигает нижней части родительского макета, затем перестает расти
и становится вместо этого прокручиваемым.
Изображение, иллюстрирующее желаемое поведение, можно найти здесь (не может загрузить его):
![enter image description here](https://i.stack.imgur.com/f7Sjy.jpg)
Проблема, похоже, заключается в том, чтобы ограничить EditText определенной высотой, чтобы он не оттолкнул другой вид от нижней части экрана. Или дать другому View атрибут, который всегда остается на экране, я не знаю.
Я пробовал несколько разных подходов, чтобы решить эту проблему с помощью XML. Тот, который я прикрепляю, просто работает, ограничивая количество строк в EditText - которое мне позже придется менять программно в зависимости от разрешения устройства. Так что это не очень желательно.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical">
<include
android:id="@+id/tripNotes_toolbar_layout"
layout="@layout/toolbar_details" />
<android.support.constraint.ConstraintLayout
android:id="@+id/tripNotes_constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/CardStyle"
android:layout_gravity="top"
android:layout_marginLeft="@dimen/card_outer_margin_left"
android:layout_marginRight="@dimen/card_outer_margin_left">
<EditText
android:id="@+id/tripNotes_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@null"
android:hint="Put your notes here"
android:inputType="textMultiLine|textCapWords"
android:lines="12"
android:maxLength="1000"
android:maxLines="12"
android:minLines="1"
android:textColor="@color/grey_12"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/tripNotes_pictureGrid"
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/tripNotes_editText"
app:layout_constraintVertical_bias="0"
app:layout_constraintVertical_weight="1"/>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
Фактический результат заключается в том, что другое представление отталкивается от экрана, если количество строк в EditText не ограничено, но я бы предпочел решение с атрибутами alyout.