Solution 1 :
This one solved my problem. I’ve put it into OnViewCreated method in the BottomSheetDialogFragment.
binding.root.addGlobalLayoutListener(true) {
val keyboardHeight =
dialog?.window?.decorView?.rootWindowInsets?.getInsets(
WindowInsetsCompat.Type.ime()
)?.bottom
binding.root.setPadding(0, 0, 0, keyboardHeight ?: 0)
}
Problem :
I have a common problem with the keyboard just a little overlapping EditText. I searched, but all the answers hadn’t worked.
I have android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
in AndroidManifest.
Here’s my layout:
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<import type="ru.express.app.domain.model.SendCheckBy" />
<variable
name="vm"
type="ru.express.app.presentation.orders.dialogs.PayAllBottomSheetVM" />
</data>
<LinearLayout
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_background="@drawable/bg_pop_up_rounded_19"
android_gravity="center_horizontal"
android_orientation="vertical"
tools_context=".android.presentation.main.geo_location_dialog.GeoLocationDialogFragment"
tools_ignore="SpUsage">
<View
android_layout_width="30dp"
android_layout_height="3dp"
android_layout_marginTop="15dp"
android_background="@drawable/bg_paging_indicator" />
<TextView
android_id="@+id/titleTextView"
style="@style/Theme.ExpressRu.Text.Bold.21sp"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_layout_marginTop="20dp"
android_gravity="center"
android_lineSpacingExtra="10dp"
android_text="@{vm.titleText}"
tools_text="Оплатить все" />
<TextView
android_id="@+id/selectPaymentTitleTextView"
style="@style/Theme.ExpressRu.Text.Bold.16sp"
android_layout_marginTop="25dp"
android_layout_marginHorizontal="13dp"
android_layout_width="match_parent"
android_gravity="start"
android_text="@string/order_finished_select_payment_option" />
<TextView
android_id="@+id/cashPaymentTextView"
style="@style/Theme.ExpressRu.Text.Regular.17sp"
android_layout_width="match_parent"
android_layout_marginHorizontal="13dp"
android_layout_marginTop="20dp"
android_text="@string/order_finished_cash"
android_textColor="@drawable/bg_text_pressed"
app_drawableEndCompat="@drawable/ic_round_red" />
<TextView
android_id="@+id/cardPaymentTextView"
style="@style/Theme.ExpressRu.Text.Regular.17sp"
android_layout_width="match_parent"
android_layout_marginHorizontal="13dp"
android_layout_marginTop="15dp"
android_text="@string/order_finished_card"
android_textColor="@drawable/bg_text_pressed"
app_drawableEndCompat="@drawable/ic_round_gray" />
<View
android_layout_width="match_parent"
android_layout_height="1dp"
android_layout_marginTop="20dp"
android_background="@color/gray_white_line" />
<TextView
android_id="@+id/chooseNumberOfChecksTitleTextView"
style="@style/Theme.ExpressRu.Text.Bold.16sp"
android_layout_marginTop="20dp"
android_layout_marginHorizontal="13dp"
android_layout_width="match_parent"
android_gravity="start"
android_text="@string/order_finished_select_number_of_checks" />
<TextView
android_id="@+id/oneCheckTextView"
style="@style/Theme.ExpressRu.Text.Regular.17sp"
android_layout_width="match_parent"
android_layout_marginHorizontal="13dp"
android_layout_marginTop="20dp"
android_text="@string/order_finished_one_check"
android_textColor="@drawable/bg_text_pressed"
app_drawableEndCompat="@drawable/ic_round_red" />
<TextView
android_id="@+id/numberOfInvoicesTextView"
style="@style/Theme.ExpressRu.Text.Regular.17sp"
android_layout_width="match_parent"
android_layout_marginHorizontal="13dp"
android_layout_marginTop="15dp"
android_text="@string/order_finished_by_number_of_invoices"
android_textColor="@drawable/bg_text_pressed"
app_drawableEndCompat="@drawable/ic_round_gray" />
<View
android_layout_width="match_parent"
android_layout_height="1dp"
android_layout_marginTop="20dp"
android_background="@color/gray_white_line" />
<TextView
android_id="@+id/sendChecksTitleTextView"
style="@style/Theme.ExpressRu.Text.Bold.16sp"
android_layout_marginTop="20dp"
android_layout_marginHorizontal="13dp"
android_layout_width="match_parent"
android_gravity="start"
android_text="@string/order_finished_select_send_request" />
<TextView
android_id="@+id/phoneTextView"
style="@style/Theme.ExpressRu.Text.Regular.17sp"
android_layout_width="match_parent"
android_layout_marginHorizontal="13dp"
android_layout_marginTop="20dp"
android_text="@string/order_finished_send_by_phone"
android_textColor="@drawable/bg_text_pressed"
app_drawableEndCompat="@drawable/ic_round_gray" />
<EditText
android_id="@+id/phoneEditText"
style="@style/Theme.ExpressRu.TextInputEditText.Default"
android_layout_width="match_parent"
android_layout_marginTop="10dp"
android_layout_marginHorizontal="13dp"
android_padding="10dp"
android_inputType="phone"
android_maxLength="12"
android_onTextChanged="@{(text, start, before, count) -> vm.updateInput(text)}"
android_text="@{vm.inputRequestText}"
android_hint="@string/order_finished_send_by_phone_hint"
android_backgroundTint="@color/white_blue_background"
app_visible="@{vm.selectedSendBy == SendCheckBy.PHONE ? true : false}" />
<TextView
android_id="@+id/mailTextView"
style="@style/Theme.ExpressRu.Text.Regular.17sp"
android_layout_width="match_parent"
android_layout_marginHorizontal="13dp"
android_layout_marginTop="15dp"
android_text="@string/order_finished_send_by_email"
android_textColor="@drawable/bg_text_pressed"
app_drawableEndCompat="@drawable/ic_round_gray" />
<EditText
android_id="@+id/mailEditText"
style="@style/Theme.ExpressRu.TextInputEditText.Default"
android_layout_width="match_parent"
android_layout_marginTop="10dp"
android_layout_marginHorizontal="13dp"
android_padding="10dp"
android_inputType="textEmailAddress"
android_onTextChanged="@{(text, start, before, count) -> vm.updateInput(text)}"
android_text="@{vm.inputRequestText}"
android_hint="@string/order_finished_send_by_email_hint"
android_backgroundTint="@color/white_blue_background"
app_visible="@{vm.selectedSendBy == SendCheckBy.EMAIL ? true : false}" />
<View
android_layout_width="match_parent"
android_layout_height="1dp"
android_layout_marginTop="25dp"
android_background="@color/gray_white_line" />
<com.google.android.material.button.MaterialButton
android_id="@+id/confirmButton"
style="@style/Theme.ExpressRu.Button.Permission"
android_layout_width="match_parent"
android_layout_marginStart="13dp"
android_layout_marginTop="16dp"
android_layout_marginEnd="13dp"
android_backgroundTint="@color/red_main"
android_text="@string/confirm"
android_textColor="@color/white" />
<Space
android_id="@+id/space"
android_layout_width="wrap_content"
android_layout_height="23dp" />
</LinearLayout>
</layout>
I tested recommendations from:
Keyboard hides BottomSheetDialogFragment
Bottom Sheet Fragment comes up with keyboard