当SoftInputKeyboard出现时,我该如何才能调整RecyclerView?

时间:2018-05-22 10:28:47

标签: android android-recyclerview window-soft-input-mode

这是我的聊天活动,当我点击TextField键盘出现但我希望只调整RecyclerView的大小,以便底部的TextField和用户信息(用户名,ProfileImage,lastOnline和后退按钮) )在顶部应始终可见。

现在一切都被推高而没有调整大小,所以只有TextField和RecyclerView可见。

我该怎么做?

P.S。对不起拼写错误我的母语是德语

  

我的XML文件

<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:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".home.ChatActivity">

<ImageButton
    android:id="@+id/chat_backButton"
    android:isScrollContainer="false"
    style="@style/Widget.AppCompat.Button.Borderless"
    android:layout_width="48dp"
    android:layout_height="44dp"
    android:foregroundGravity="top"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"
    android:src="@mipmap/ic_back_black"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/chat_profileImage"
    android:isScrollContainer="false"
    android:foregroundGravity="top"
    android:layout_width="32dp"
    android:layout_height="32dp"

    android:layout_marginEnd="8dp"
    android:src="@drawable/placeholder_image"
    app:layout_constraintBottom_toBottomOf="@+id/chat_backButton"
    app:layout_constraintEnd_toStartOf="@+id/chat_timeTv"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintHorizontal_chainStyle="packed"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/chat_backButton" />

<TextView
    android:id="@+id/chat_lastOnline"
    android:isScrollContainer="false"
    android:foregroundGravity="top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="zul. Online um 18:16"
    android:textColor="#a2a2a2"
    android:textSize="10sp"
    app:layout_constraintBottom_toBottomOf="@+id/chat_backButton"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toEndOf="@+id/chat_profileImage"
    app:layout_constraintTop_toBottomOf="@+id/chat_userName" />

<TextView
    android:id="@+id/chat_userName"
    android:isScrollContainer="false"
    android:foregroundGravity="top"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:fontFamily="sans-serif"
    android:gravity="center_horizontal"
    android:text="Max Mustermann"
    android:textColor="@color/textGray"
    android:textSize="12sp"
    app:layout_constraintBottom_toTopOf="@+id/chat_timeTv"
    app:layout_constraintStart_toEndOf="@+id/chat_profileImage"
    app:layout_constraintTop_toTopOf="@+id/chat_backButton"
    app:layout_constraintVertical_chainStyle="packed" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/chat_recyclerView"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginBottom="8dp"
    android:layout_marginTop="64dp"
    android:isScrollContainer="true"
    android:overScrollMode="never"
    app:layout_constraintBottom_toTopOf="@+id/relativeLayout2"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

</android.support.v7.widget.RecyclerView>


<RelativeLayout
    android:id="@+id/relativeLayout2"
    android:layout_width="match_parent"
    android:layout_height="32dp"
    android:layout_marginBottom="4dp"
    android:isScrollContainer="false"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent">

    <EditText
        android:id="@+id/chat_textfield"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:background="@drawable/home_messages_textfield_bg"
        android:ems="10"
        android:hint="Nachricht schreiben..."
        android:inputType="textCapSentences"
        android:paddingBottom="4dp"
        android:paddingEnd="38dp"
        android:paddingStart="16dp"
        android:paddingTop="4dp"
        android:textColorHint="#a2a2a2"
        android:textSize="16sp" />

    <ImageButton
        android:id="@+id/chat_sendButton"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:layout_width="24dp"
        android:layout_height="match_parent"
        android:layout_alignBottom="@id/chat_textfield"
        android:layout_alignEnd="@id/chat_textfield"
        android:layout_alignTop="@id/chat_textfield"
        android:layout_marginBottom="4dp"
        android:layout_marginEnd="4dp"
        android:layout_marginTop="4dp"
        android:padding="0dp"
        android:scaleType="centerCrop"

        android:src="@drawable/chats_sent_button_bg" />
</RelativeLayout>

  

我的清单

android:windowSoftInputMode="adjustResize|stateHidden"

0 个答案:

没有答案