Reputation: 1427
I am using recyclerview and one EditText which is used for filter in recyclerview. I have used adjustpan for viewing Edittext on top of soft keyboard. When keyboard is opened my recyclerview goes up and cuts the first row almost half.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativemain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#fff">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:layout_below="@+id/include"
android:layout_marginTop="-20dp"/>
<include
android:id="@+id/include2"
layout="@layout/setting_header"/>
<include
android:id="@+id/notifyBlue"
layout="@layout/notify_bluetooth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/include"
android:layout_alignParentTop="true"/>
<include
android:id="@+id/include"
layout="@layout/header"
android:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/include2"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="false"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"
android:id="@+id/recycleView"
android:visibility="visible"
android:layout_above="@+id/etSearch"
android:padding="5dp"
android:layout_below="@+id/include" />
<ImageView
android:id="@+id/imgbackbutton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:background="@drawable/circle_purpleforbutton"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="4dp"
android:paddingTop="5dp"
android:src="@drawable/menu_button"
android:layout_above="@+id/etSearch"
android:layout_marginBottom="20dp" />
<include
android:id="@+id/rlFooter"
layout="@layout/footer"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<ProgressBar
android:id="@+id/pBarMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone"/>
<com.StampWallet.customClasses.FocusClearingEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/etSearch"
android:layout_above="@+id/rlFooter"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:hint="type to search a store"
android:inputType="text"
android:gravity="center_horizontal"
android:background="@android:color/white"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:textColor="#000"
android:visibility="gone" />
</RelativeLayout>
Any help?
Upvotes: 1
Views: 661
Reputation: 1427
I found solution.
What I have done to solve this.. I have added android:windowSoftInputMode="adjustResize"
to my activity in Manifest.
And hide and show my header and user info view as soft keyboard opens and close....
My EditText listner for search
etSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if (b) {
if (include != null)
include.setVisibility(View.GONE);
if (include2 != null)
include2.setVisibility(View.GONE);
if (notifyView != null)
notifyView.setVisibility(View.GONE);
} else {
if (include != null)
include.setVisibility(View.VISIBLE);
if (include2 != null)
include2.setVisibility(View.VISIBLE);
}
}
});
This solved my problem
Upvotes: 1
Reputation: 4044
Add this attribute to your AndroidManifest.xml file.This will solve your problem.
<activity
android:name=".YourActivityName"
android:windowSoftInputMode="adjustPan" />
Upvotes: 0
Reputation: 4837
Adding "adjustresize" to your manifest will solve the problem
android:windowSoftInputMode="adjustResize"
Upvotes: 0