Android 当键盘打开时,碎片不会调整大小

Android 当键盘打开时,碎片不会调整大小,android,android-fragments,android-softkeyboard,android-constraintlayout,Android,Android Fragments,Android Softkeyboard,Android Constraintlayout,我有一个EditText,它监听活动上的点击事件,并使用fragmentTransaction.add()启动一个片段;活动和片段都有一个ConstraintLayout作为根视图组。片段布局如下(为了简洁起见,省略了一些元素): 我尝试在AndroidManifest中添加android:windowSoftInputMode=“adjustResize”,并以编程方式作为一些类似问题的答案。这个问题是由于我添加了一些代码,使状态栏完全透明,我在本文中找到了这些代码 将android:fi

我有一个EditText,它监听活动上的点击事件,并使用
fragmentTransaction.add()
启动一个片段;活动和片段都有一个ConstraintLayout作为根视图组。片段布局如下(为了简洁起见,省略了一些元素):



我尝试在AndroidManifest中添加
android:windowSoftInputMode=“adjustResize”
,并以编程方式作为一些类似问题的答案。

这个问题是由于我添加了一些代码,使状态栏完全透明,我在本文中找到了这些代码

android:fitsystemwindows=“true”
添加到片段布局解决了这个问题

<?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:id="@+id/fragment_CitySelection"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="25dp"
    android:background="@color/white"
    android:clickable="true"
    android:focusable="true"
    tools:context=".CitySelectionFragment">


    <EditText
        android:id="@+id/city_AutoCompleteTextView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:background="@layout/rounded_border_edittext"
        android:hint="Ville"
        android:paddingStart="8dp"
        android:paddingLeft="8dp"
        android:paddingTop="6dp"
        android:paddingEnd="8dp"
        android:paddingRight="8dp"
        android:paddingBottom="10dp"
        android:textSize="22sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/back_ImageButton" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/cities_RecyclerView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="12dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/city_AutoCompleteTextView" />

</androidx.constraintlayout.widget.ConstraintLayout>