How can i create a sticky footer that wont be moved up with the view when the softkey keyboard popups up?
Below is an image example of my current setup and what i want
Either add this as scrollbar's XML attribute
android:isScrollContainer="false"
or add this in Activity's tag in Manifest
android:windowSoftInputMode="adjustPan"
Just add this line in your onCreate
, When this option set the window not adjust for a shown input method. :
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
I've come across a pretty similar problem with the differences that a) I wasn't using a ScrollView at first and b) the item I didn't want to move was a simple TextView.
Here's the answer I found: click
What I did to fix it:
adjustResize
android:layout_alignParentBottom="true"
, while this will move your navigation bar to the bottom of the screen, it also means that the keyboard can move it up because of "adjustResize"android:layout_height="wrap_content"
in combination with android:layout_below="@id/MyScrollView"
(so the layout will use up all the space it can get between the ScrollView and the bottom of the screen) and android:gravity="bottom"
to simply have everything at the bottom of the layout.android:layout_height="match_parent"
instead of android:layout_alignParentBottom="true"
and android:layout_height="wrap_content"
but I didn't fully test it like that.I am very late to answer but I ran into same situation lately. I followed another approach to solve this issue and that was rather than using RelativeLayout
or LinearLayout
, using CoordinatorLayout
and having behavior applied to BottomNavigtaionView
to show/hide it with scrolling to top or bottom (the same way we see CollapsingToolBar or AppBarLayout).
The built in behavior used for BottomNavigationView is app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
You can read all steps in detail from my another answer here.
P.S. I posted it as an answer rather than a comment because sometimes we just look for answers and ignore the comments and I believe it could be a good approach to solve this issue, so you should not ignore it and give it a read once. Thanks.
I tried a lot of solutions found on SO and only adding android:windowSoftInputMode="adjustNothing" into the manifest for the activity worked for me:
<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustNothing">
Associated layout:
<RelativeLayout
...
<android.support.v4.widget.NestedScrollView
...
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.BottomNavigationView
...
design:menu="@menu/navigation"/>
</RelativeLayout>