I have bottomsheet fragment what shows to user answears to his comment. At the bottom of bottom sheet we have edit text, where user can add new comment. So, when soft keyboard opened the bottomsheet staes above keyboard and its top moved far beyond the screen. But bottom sheet should to resize when keyboard is open.
Here is my code:
<android.support.design.widget.CoordinatorLayout
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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include android:id="@+id/toolbar_layout"
layout="@layout/partial_toolbar" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list_comments"
android:layout_below="@+id/toolbar_layout"
android:layout_width="match_parent"
android:overScrollMode="always"
android:layout_height="match_parent"/>
<View
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_above="@+id/comment_container"
android:layout_alignBaseline="@+id/list_comments"
android:background="@drawable/elevation_bottom"/>
<LinearLayout
android:id="@+id/comment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ebffffff"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="@dimen/vertical_spacing"
android:paddingEnd="@dimen/horizontal_spacing"
android:paddingStart="8dp"
android:paddingTop="@dimen/vertical_spacing">
<android.support.v7.widget.AppCompatImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:src="@drawable/ic_add_blue_small"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/bg_message_field"
android:gravity="center_vertical"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edit_comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/transparent"
android:hint="@string/comments_add_comment_hint"
android:inputType="textMultiLine"
android:maxLength="200"
android:maxLines="3"
android:minLines="1"
android:paddingBottom="8dp"
android:paddingEnd="0dp"
android:paddingStart="8dp"
android:paddingTop="8dp"
android:textSize="14sp"
app:fontFamily="@font/lora_regular"/>
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@color/transparent"
app:srcCompat="@drawable/ic_send_message"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Activity at manifest (this activity opens dialog)
<activity
android:name=".presentation.ui.category.CategoryDetailsActivity"
android:configChanges="locale|orientation|screenSize|keyboard"
android:windowSoftInputMode="adjustResize"
android:windowTranslucentNavigation="true"
android:windowTranslucentStatus="true"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.Main.NoActionBar" />
Also I put this code to method setupDialog
dialog.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);