Я очень новичок в использовании ConstraintLayout. Пытаясь научиться использовать это, я решил создать для себя простое приложение для чата.
У меня есть RecyclerView для отображения списка чатов и ConstraintLayout под ним для ввода моего сообщения (мой код находится внизу). Я бы очень хотел использовать атрибут fill-parent, но обнаружил, что он устарел.
Итак, я установил, что мой RecyclerView будет ограничен снизу ConstraintLayout под ним. Исходя из этого, я ожидаю, что RecyclerView «сжимается», когда клавиатура подходит для ввода моего сообщения. Однако он этого не делает, а остается на полной высоте.
Есть ли способы решить эту проблему?
Вот мой код:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
tools:context=".StreamPlayer.StreamPlayerActivity">
<android.support.v7.widget.RecyclerView
android:id="@id/ChatRecyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@id/ChatTypingLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/chat_layout" /
<android.support.constraint.ConstraintLayout
android:id="@id/ChatTypingLayout"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<EditText
android:id="@id/ChatNameEditText"
android:layout_width="0dp"
android:layout_height="match_parent"
android:hint="@string/ChatNameEditText"
android:inputType="text"
android:maxLines="1"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/ChatMessageEditText"
app:layout_constraintStart_toStartOf="parent"
android:textSize="10dp"/>
<EditText
android:id="@id/ChatMessageEditText"
android:layout_width="0dp"
android:layout_height="match_parent"
android:hint="@string/ChatMessageEditText"
android:inputType="textLongMessage"
android:maxLines="3"
app:layout_constraintHorizontal_weight="4"
app:layout_constraintLeft_toRightOf="@id/ChatNameEditText"
app:layout_constraintRight_toLeftOf="@id/ChatSendButton"
android:textSize="10dp"/>
<Button
android:id="@id/ChatSendButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="@string/ChatSendButton"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintLeft_toRightOf="@id/ChatMessageEditText"
app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
Это когда клавиатура не подошла
Это происходит, когда появляется клавиатура
Заранее спасибо