0

In one of my signIn fragments, I want the layout elements to move up while the user is typing. I looked up many questions on stackoverflow but couldn't find an answer.

Links I have gone to:

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.moodboard">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat"
        >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustPan|adjustResize"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

layout.xml

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView2">

        <TextView
            android:id="@+id/textView8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="36dp"
            android:text="Your E-mail:"
            android:textColor="#000"
            android:textSize="24sp"
            android:textStyle="bold"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
             />

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/edit_text_email_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toBottomOf="@+id/textView8"

            >
            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/editTextEmail"
                android:layout_width="match_parent"
                android:layout_height="55dp"
                android:layout_marginStart="64dp"
                android:layout_marginTop="40dp"
                android:layout_marginEnd="64dp"
                android:background="@drawable/email_edit_text"
                android:hint="example@example.com"
                android:textAlignment="center"
                android:textSize="18sp"
                android:textStyle="bold"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                />
        </com.google.android.material.textfield.TextInputLayout>

        <Button
            android:id="@+id/email_submit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/email_submit"
            android:text="Next"
            android:textColor="#ffffff"
            android:textSize="18sp"
            android:textStyle="bold"
            android:layout_marginTop="40dp"
            android:layout_marginStart="100dp"
            android:layout_marginEnd="100dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/edit_text_email_container" />
    </androidx.constraintlayout.widget.ConstraintLayout>

The Layout image

Mood Board
  • 59
  • 3
  • 7
  • can you add an image of what output you getting exactly ? Because I tested the xml it is just fine – AgentP Jun 29 '20 at 11:34
  • I have added the edit. – Mood Board Jun 29 '20 at 11:46
  • You're not even using a `FullScreenActivity` then have you tried `android:windowSoftInputMode="adjustPan`? Because, with FullScreenActivity, it becomes a mess but without it, `AdjustPan` works great. Also, put your layout in a Root `ScrollView`, it will work. You're already using `wrap_content` for height so adding a `ScrollView` won't need any change. – Lalit Fauzdar Jul 03 '20 at 09:42
  • yeah I have tried `android:windowSoftInputMode="adjustPan` and also put the layout in a root `ScrollView` & `NestedScrollView` but there is no difference. – Mood Board Jul 03 '20 at 13:19

0 Answers0