0

In my layout I have an edit text and an image view. The image view height is set to match parent layout.

What I want to happen is, when the user selects the edit text and the keyboard appears, the edit text should be above the keyboard whilst the image view should stay in the exact position as it was before the keyboard appeared. Right now the whole layout is pushed up but I want the image view to not move.

I have tried using adjustPan, adjustResize, adjustNothing but they don't achieve what I want.

Before keyboard. I need this image to be exactly where it is and not move once the keyboard appears

Before keyboard. I need this image to be exactly where it is once the keyboard appears.

The whole layout moves up when keyboard appears

But the image moves up which is not what I want. Basically I need the keyboard to overlap the image.

Here is my xml layout:

<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/image_view"
    android:scaleType="fitCenter"/>

<View
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:id="@+id/transparent_view"
    android:background="@android:color/black"
    android:alpha="0.6"
    app:layout_constraintTop_toTopOf="@id/message_edit_text"
    app:layout_constraintBottom_toBottomOf="parent"/>

<ImageView
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:id="@+id/gallery_icon"
    app:layout_constraintDimensionRatio="1:1"
    tools:src="@drawable/gallery_icon"
    android:padding="10dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintBottom_toBottomOf="@id/message_edit_text"
    app:layout_constraintTop_toTopOf="@id/message_edit_text"/>

<EditText
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:id="@+id/message_edit_text"
    android:hint="Type a message..."
    android:layout_marginBottom="10dp"
    android:padding="10dp"
    android:textColor="@color/white"
    android:maxLines="5"
    android:textColorHint="@android:color/darker_gray"
    android:background="@null"
    app:layout_constraintLeft_toRightOf="@+id/gallery_icon"
    app:layout_constraintRight_toLeftOf="@id/send_button"
    app:layout_constraintBottom_toBottomOf="parent"/>

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/send_button"
    android:layout_marginBottom="12dp"
    android:layout_marginRight="12dp"
    android:clickable="true"
    android:visibility="visible"
    android:backgroundTint="@color/green"
    app:borderWidth="0dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@id/transparent_view"
    app:layout_constraintBottom_toTopOf="@id/transparent_view"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Evian Pringle
  • 45
  • 2
  • 9
  • 1
    It will help to share some code of your xml layout so we can understand why those manifest settings are not working potentially – David Kroukamp Dec 10 '20 at 15:51
  • I think this is a duplicate specifically in the accepted answer where it says: "If your container is not changing size, then you likely have the height set to "match parent". If possible, set the parent to "Wrap Content", or a constraint layout with constraingts to top and bottom of parent." – David Kroukamp Dec 10 '20 at 15:54
  • Nope I tried wrapping content and using a constraint layout with constraints to top and bottom. Doesn't work – Evian Pringle Dec 10 '20 at 15:58
  • Well then please do post some code so we can replicate your issue unless you just want shot in the dark answers – David Kroukamp Dec 10 '20 at 16:01
  • Also that question suggests using a scrollable view. I don't want it to scroll – Evian Pringle Dec 10 '20 at 16:04

1 Answers1

0

You might wanna check your AndroidManifest.xml and search for your activity. If you found android:windowSoftInputMode="adjustResize, just delete it.

Hiraeths
  • 380
  • 3
  • 16