I have the following layout in an activity.
<CoordinatorLayout ...>
<ScrollView ...>
<LinearLayout
...
android:orientation="vertical">
<!-- Some stuff -->
<EditText ...>
<!-- Some more stuff -->
<View
android:id="@+id/keyboard_extender"
...>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/bottom_sheet"
android:orientation="vertical"
...
app:layout_behavior="android...BottomSheetBehavior">
<!-- Even more stuff -->
</LinearLayout>
</CoordinatorLayout>
and I want that the keyboard shouldn't push up the bottom_sheet
but it should push up the keyboard_extender
. Please note that the bottom_sheet
is not a BottomSheetDialog
but just a view using the android.support.design.widget.BottomSheetBehavior
. This can't be changed to a BottomSheetDialog
because I want the rest of the screen to remain active at the same time as the bottom_sheet
I never set the visibility of the bottom_sheet
to View.GONE
. I only change its state from BottomSheetBehavior.EXPANDED
to BottomSheetBehavior.COLLAPSED
and back. Also, I want the bottom_sheet
to be visible only when the keyboard isn't.
Since I need that the keyboard_extender
should always be above the keyboard, I have set in the AndroidManifest.xml that android:windowSoftInputMode="adjustResize"
(which I assume is unavoidable)
I have a method which when called should hide the keyboard and show the bottom_sheet
, but the problem I'm facing is that the bottom_sheet
starts animating to BottomSheetBehavior.EXPANDED
at the same time that the keyboard starts hiding, and when the keyboard starts hiding, the screen is actually resized because of the windowSoftInputMode="adjustResize"
and the bottom_sheet
starts expanding from the top of the keyboard and it doesn't move down along with the keyboard. So, when the keyboard completely hides, the bottom_sheet
is actually sitting in the middle of the screen (just above the height of the keyboard).
Ideally, I'd like that the keyboard starts hiding and the bottom_sheet
starts expanding at the same time, but the bottom_sheet
starts expanding from the bottom of the screen and not the top of the keyboard.
The very hacky fix I'm currently using to overcome this issue is to delay the expanding of the bottom_sheet
by SoftInput.KEYBOARD_POPUP_DELAY
, which seems to be working for the time being. Is there any cleaner alternative?