Element fixed to the top of the keyboard

1

I created a RelativeLayout with property match_parent at the time so I can fill the entire screen. Inside it I insert a LinearLayout with property alignParentBottom having value true to fix the element in the footer.

When I click and focus on EditText , my keyboard overlaps the element. I would like this LinearLayout to remain fixed on the device keyboard.

To be clearer I took this image from the Twitter application:

Code:

<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="O que esta acontecendo?"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:background="#666"
        android:layout_alignParentBottom="true"
        android:layout_alignParentStart="true">

    </LinearLayout>
</RelativeLayout>

Below is a GIF showing the code above running. When the focus on EditText is given, the gray part is overridden by the keyboard. I already tried to use android:windowSoftInputMode="adjustPan|adjustResize" in my Activity , but it did not work.

How do I make my element stay fixed to the top of the keyboard without overlapping?

    
asked by anonymous 19.12.2016 / 19:16

1 answer

1

Have you tried adding adjustPan to your manifest?

Example:

<activity
   android:name=".SuaActivity"
   android:windowSoftInputMode="adjustPan|adjustResize">
</activity>

This will make when the keyboard is opened, it will push the entire layout to stay on top of the keyboard.

    
19.12.2016 / 20:53