4

I have an EditText which listens to click events on an activity and launches a fragment using fragmentTransaction.add(); both the activity and the fragment have a ConstraintLayout as a root ViewGroup. The fragment layout is as follows (Some elements has been omitted for brevity):

<?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>

I tried adding android:windowSoftInputMode="adjustResize" in AndroidManifest and programmatically as of answers in some similar questions.

matrixersp
  • 535
  • 5
  • 17

1 Answers1

3

The problem is caused by some code I added to make the status bar completely transparent, which I found in this answer.

Adding android:fitsSystemWindows="true" to the fragment layout solved the problem.

matrixersp
  • 535
  • 5
  • 17