1

EDIT: Looks like this bug is the main problem here

In my application's MainActivity I have a custom bottom navigation which is a horizontal recyclerview. I have an access to this recyclerview in all of my Fragments for navigation. The thing is when I focus on an edittext inside my fragment, soft input method moves that recyclerview up, how can I force the screen to pan just for the items in my Fragment's layout.

[![here is my fragment with activity's bottom navigation][2]][2]

[![enter image description here][3]][3]

I tried to put android:windowSoftInputMode="adjustPan" and then android:windowSoftInputMode="adjustNothing" to my activity in my Manifest.

then I tried to do those programatically inside my Activity.

then I tried to do the same inside my Fragment this time, nothing helped. Literally no way to make the keyboard ignore the activity.

Main Activity layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="#d9d5ce"
    android:orientation="vertical"
    android:focusableInTouchMode="true"
    >

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@drawable/toolbar_background"
        android:theme="@style/ToolBarStyle"
        app:layout_collapseMode="pin"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:titleTextAppearance="@style/TextAppearance.AppCompat.Subhead" />

    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/recycler_view"
        android:layout_gravity="center"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">


    </FrameLayout>


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="65dp"
        android:layout_alignParentBottom="true"
        android:background="@color/accent"
        android:fadingEdge="vertical|horizontal"
        android:fadingEdgeLength="60dp"
        android:fillViewport="false"
        android:requiresFadingEdge="horizontal|vertical"
        app:layoutManager="android.support.v7.widget.LinearLayoutManager">


    </android.support.v7.widget.RecyclerView>


</RelativeLayout>

Edit: I already tried possible solutions like android:windowSoftInputMode="adjustPan" the problem is when the edittext inside fragment gain focus, Recyclerview in my activity moves up and I lost pan

FYI: my fragment's root layout is ScrollView

Ege Kuzubasioglu
  • 5,000
  • 10
  • 38
  • 76

3 Answers3

0

Wrap up a ScrollView (as RootLayout ) above the RelativeLayout and the

View would adjust and move up accordingly !!

<ScrollView
  android:width="match_parent"
  android:height="match_parent"
  ....
  .... >
     <RelativeLayout
       .....
       .....

Edit:-

If you want to hide a view after the keyboard opens , you can try this.

Santanu Sur
  • 8,836
  • 7
  • 24
  • 43
0

If you want to hide keyboard, you can try this.

 public static void hideSoftKeyboard(Activity activity) {
    InputMethodManager inputMethodManager =
            (InputMethodManager) activity.getSystemService(
                    Activity.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(
            activity.getCurrentFocus().getWindowToken(), 0);
  }
Sudhir singh
  • 707
  • 9
  • 14
0

I solved this by observing the keyboard and set visibility of the nav bar. here is the full solution:

https://medium.com/@egek92/beaware-of-android-bug-5497-for-your-own-sake-19cf76abb7e5

Ege Kuzubasioglu
  • 5,000
  • 10
  • 38
  • 76