Rodrigo
Rodrigo

Reputation: 1

Android layout doesn´t resize when keyboard shows

as title says, i have a problem resizing my layout when keyboard appears, I did the same in new project and it works, nope in this project:

And this is the include file:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/dashboard_title_bg">

<TextView
    android:id="@+id/actionBarCentralTextView"
    style="@style/MainTitleActionBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.6" />

<ImageButton
    android:id="@+id/btActionBarMenuText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="16dp"
    android:background="?android:selectableItemBackground"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.6" />

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/back_container_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.6">

    <ImageButton
        android:id="@+id/btActionBarNotificationsText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:background="?android:selectableItemBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/tvSecondTitleText"
        style="@style/SecondaryTitleActionBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

Anyone knows why it is not resizing? Thanks,

Upvotes: 0

Views: 559

Answers (1)

Mehrbod Khiabani
Mehrbod Khiabani

Reputation: 543

By it's standard documentation:

Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows.

I think your problem would be solved by adding android:fitsSystemWindows=true to your root view.

Upvotes: 1

Related Questions