0

I know this is a common problem but I can't figure out. I have this layout:

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

    <VideoView
        android:id="@+id/video_intro"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <ImageView
        android:id="@+id/back_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_back"
        android:layout_marginTop="30dp"
        android:layout_marginStart="16dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/email_field"
        android:layout_width="320dp"
        android:layout_height="wrap_content"
        android:background="@drawable/white_borders_et"
        android:fontFamily="@font/exo_bold"
        android:hint="@string/sign_in_email"
        android:inputType="textEmailAddress"
        android:textColor="@color/white"
        android:textColorHint="@color/white"
        android:textAlignment="center"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toTopOf="@id/access_btn"/>

    <Button
        android:id="@+id/access_btn"
        style="@style/ButtonRed"
        android:layout_width="150dp"
        android:layout_height="47dp"
        android:text="@string/intro_access"
        android:textAllCaps="false"
        android:textSize="20sp"
        android:layout_marginTop="12dp"
        android:layout_marginBottom="16dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

When keyboard appear after tapped on an EditText, back_icon ImageView is pushed up.

I tried with android:windowSoftInputMode="adjustPan" and others parameters in Manifest but nothing is working. Thanks in advance

EDIT: Sorry, I omitted the problem but I realized later that that was the cause of everything: I have a full screen VideoView (xml code updated). When the keyboard disappear the back_icon is like "obfuscated" by VideoView (the icon is no longer visible but is clickable, and click listener is triggered when tapped.). Even if I give elevation to back_icon the problem remains.

  • In the solution i have posted below, it works just fine. How did you add it to the manifest file? Lets have a look at you manifest file. – braop Jan 03 '21 at 16:55

1 Answers1

0

The solution is simple:

Add android:windowSoftInputMode="stateVisible|adjustResize" to your manifest file in the activity tag. As below:

<activity android:name=".YourActivity"
          android:windowSoftInputMode="stateVisible|adjustResize">
            //............
        </activity>
braop
  • 186
  • 12