1

Fragment is not scrolling when keyboard is up, meanwhile similar setup has work for activities. I added android:windowSoftInputMode="adjustResize|stateAlwaysHidden in the activity that is hosting the fragment, and added android:fitsSystemWindows="true" to the root layout of the fragment. I'm using Butterknife tho. Here are the code:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@drawable/bg_create_account">

<View
    android:id="@+id/vail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black_two" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_gravity="center"
        android:background="@color/black"
        android:gravity="center_horizontal"
        android:paddingTop="@dimen/status_bar_height">

        <TextView
            style="@style/ProximaNova18PtWhite"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:lineSpacingExtra="4sp"
            android:text="@string/create_account"
            android:textAllCaps="true"
            android:textColor="@color/white"
            android:textSize="16sp" />


    </androidx.appcompat.widget.Toolbar>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <LinearLayout
            android:id="@+id/inner_root"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <View
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/username_layout"
                style="@style/LoginTextInputLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/content_margin"
                android:layout_marginEnd="@dimen/content_margin"
                android:hint="@string/username"
                app:hintAnimationEnabled="true"
                app:hintTextAppearance="@style/ProximaNova14Pt"
                app:hintTextColor="@color/white">

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/username_edit"
                    style="@style/LoginEdittextStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:importantForAutofill="noExcludeDescendants"
                    android:inputType="textEmailAddress"
                    android:textColorHint="@color/white"
                    tools:text="dewe" />

            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/email_layout"
                style="@style/LoginTextInputLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/content_margin"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="@dimen/content_margin"
                android:hint="@string/email"
                app:hintAnimationEnabled="true"
                app:hintTextAppearance="@style/ProximaNova14Pt"
                app:hintTextColor="@color/white">

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/email_edit"
                    style="@style/LoginEdittextStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:importantForAutofill="noExcludeDescendants"
                    android:inputType="textEmailAddress"
                    android:textColorHint="@color/white"
                    tools:text="dewe" />

            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/password_layout"
                style="@style/LoginTextInputLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/content_margin"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="@dimen/content_margin"
                android:hint="@string/password"
                app:hintAnimationEnabled="true"
                app:hintTextAppearance="@style/ProximaNova14Pt"
                app:hintTextColor="@color/white">

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/password_edit"
                    style="@style/LoginEdittextStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:importantForAutofill="noExcludeDescendants"
                    android:inputType="textPassword"
                    android:textColorHint="@color/white"
                    tools:text="dewe" />

            </com.google.android.material.textfield.TextInputLayout>

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/confirm_password_layout"
                style="@style/LoginTextInputLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/content_margin"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="@dimen/content_margin"
                android:hint="@string/confirm_password"
                app:hintAnimationEnabled="true"
                app:hintTextAppearance="@style/ProximaNova14Pt"
                app:hintTextColor="@color/white">

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/confirm_password_edit"
                    style="@style/LoginEdittextStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:importantForAutofill="noExcludeDescendants"
                    android:inputType="textPassword"
                    android:textColorHint="@color/white"
                    tools:text="dewe" />

            </com.google.android.material.textfield.TextInputLayout>

            <androidx.appcompat.widget.AppCompatCheckBox
                android:id="@+id/checkbox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginStart="@dimen/content_margin"
                android:layout_marginTop="40dp"
                android:layout_marginEnd="@dimen/content_margin"
                android:checked="true"
                android:hint="@string/i_agree_to_all_the_terms_and_conditions"
                android:padding="0dp"
                android:textAppearance="@style/ProximaNova14Pt"
                android:textColorHint="@color/white"
                app:buttonTint="@color/white" />


            <androidx.appcompat.widget.AppCompatButton
                android:id="@+id/create_account_button"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_marginStart="@dimen/content_margin"
                android:layout_marginTop="40dp"
                android:layout_marginEnd="@dimen/content_margin"
                android:background="@drawable/bg_login_button"
                android:fontFamily="@font/proxima_nova_regular"
                android:lineSpacingExtra="4sp"
                android:text="@string/create_account_button"
                android:textAllCaps="true"
                android:textColor="@color/white"
                android:textSize="18sp" />

            <View
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />

            <FrameLayout
                android:id="@+id/terms"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@drawable/text_view_button_selector"
                android:layout_marginBottom="@dimen/default_margin"
                android:padding="@dimen/default_margin_half">

                <TextView
                    style="@style/ProximaNova14Pt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/view_terms_and_conditions" />

            </FrameLayout>

            <View
                android:id="@+id/stub"
                android:layout_width="match_parent"
                android:layout_height="56dp"
                android:visibility="gone" />

        </LinearLayout>

    </androidx.core.widget.NestedScrollView>

</LinearLayout>

</FrameLayout>

Here's an except from the manifest:

<activity
        android:name=".view.EntranceActivity"
        android:configChanges="orientation"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.Launcher"
        android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />

And the Activity that host the fragment:

@Layout(R.layout.activity_entrance)

public class EntranceActivity extends BaseActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    router.newRootScreen(new Screens.LoginScreen());
}

@Override
protected void callInjections() {
    injection().inject(this);
}
Dr4ke the b4dass
  • 1,184
  • 2
  • 17
  • 40

1 Answers1

2

After I removed this line from the activity that host the fragment, it works:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

This was setting the fullscreen mode, and thus prevent adjustResize from working

Dr4ke the b4dass
  • 1,184
  • 2
  • 17
  • 40
  • It's a known "bug" and is "working as intended" by Google: https://issuetracker.google.com/issues/36911528 If you want to keep fullscreen try solutions above: https://stackoverflow.com/questions/7417123/android-how-to-adjust-layout-in-full-screen-mode-when-softkeyboard-is-visible – Ely Dantas Dec 28 '20 at 04:13