0

I have a recycler-view with a sample background in my activity but I'm stuck in an error. Whenever keyboard popups in the activity, the background of recycler-view gets shrink. How to avoid this thing. Means how to stop it from being shrinking ? Here are the images attached below.

normal Image

shrinked background

XML Code:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/splash_bg"
    tools:context=".MainActivity">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/editText" />

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="5dp"
        android:layout_marginEnd="15dp"
        android:layout_marginStart="15dp"
        android:layout_marginTop="5dp"
        android:background="#fff"
        android:hint="Your text here"
        android:inputType="text"
        android:padding="12dp"
        android:textSize="24sp" />

</RelativeLayout>
Ahsan Arif
  • 65
  • 1
  • 1
  • 7

3 Answers3

0

In the tag of the recyclerview container activity declared in manifest add

android:windowSoftInputMode="stateHidden|adjustNothing"

like

 <activity
    android:name=".YourActivityName"
    android:windowSoftInputMode="stateHidden|adjustNothing" />
Vir Rajpurohit
  • 1,869
  • 1
  • 10
  • 23
0

add the image to your background of layout, not in recyclerview. And also recyclerview's item should have no background color except its necessary to widgets.

Smeet Bhatt
  • 66
  • 1
  • 10
0

Set attribute android:windowSoftInputMode to be "adjustPan" in your AndroidManifest.xml under your activity:

<activity
    android:name=".YourActivityName"
    android:windowSoftInputMode="adjustPan" />
Edric
  • 24,639
  • 13
  • 81
  • 91
Anusree
  • 1
  • 1