1

android:IsScrollContainer does not working after screen transition.

I have the following layout defined:

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

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/top_layout"
            android:layout_width="0dp"
            android:layout_height="66dp"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent">

        </androidx.constraintlayout.widget.ConstraintLayout>

        <ScrollView
            android:id="@+id/scroll_view"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:isScrollContainer="false"
            app:layout_constraintTop_toBottomOf="@id/top_layout"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintBottom_toTopOf="@id/bottom1">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:isScrollContainer="false"
                android:padding="16dp">

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/last_name_field"
                    android:layout_width="0dp"
                    android:layout_height="34dp"
                    android:layout_marginTop="8dp"
                    android:paddingStart="8dp"
                    android:paddingEnd="8dp"
                    app:hintAnimationEnabled="false"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintBottom_toBottomOf="parent"
                    android:inputType="text"
                    android:textSize="14sp"/>

            </androidx.constraintlayout.widget.ConstraintLayout>

        </ScrollView>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/bottom1"
            android:layout_width="0dp"
            android:layout_height="74dp"
            android:background="@color/colorPrimaryDark"
            app:layout_constraintTop_toBottomOf="@id/scroll_view"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintBottom_toTopOf="@id/bottom2">

        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/bottom2"
            android:layout_width="0dp"
            android:layout_height="66dp"
            android:background="@color/colorPrimary"

            app:layout_constraintTop_toBottomOf="@id/bottom1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Inside the scroll view is the EditText, and there is a fixed layout above and below the scroll view.

When the Keyboard is displayed, I do not want to display the bottom Layout on the keyboard, so I set isScrollContainer to false.

My application uses NavController to perform screen transitions, but in the following cases isScrollContainer may not work.

(TargetFragment is above layout.)

  • A case that works.

(Select Navigation Drawer menu) -> TargetFragment

  • Cases that don't work.

(Select Navigation Drawer menu) -> OtherFragmnet -> (navigate) -> TargetFragment(doesn't work)

Why is isScrollContaier = false not effective after navigate the NavController even though the layout is exactly the same?

R7G
  • 1,000
  • 1
  • 10
  • 15
  • [isScrollContainer](https://stackoverflow.com/questions/5308247/what-does-androidisscrollcontainer-do) attribute does not handle soft input mode. To block this behavior You should add `android:windowSoftInputMode="adjustNothing"` in manifest under `Activity` or you can also set it at runtime as required . – ADM Apr 17 '20 at 03:32
  • @ADM Thanks for the answer. Setting adjustNothing works for sure, but when the keyboard is displayed the layout of the scroll view is not resized and I can't see the bottom. In the actual layout there is a lot of content in the scroll view. – Nobuhito Suzuki Apr 17 '20 at 04:21

0 Answers0