Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Keyboard covers an EditText in a BottomSheetDialog

Posted on November 11, 2022 By

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

READ  [FIXED] kotlin - Ensuring repository is singleton in android
Powered by Inline Related Posts
Android Tags:android, android-softkeyboard, keyboard, kotlin

Post navigation

Previous Post: [FIXED] android developer api – there is a ‘Late Initialization Error’ during flutter development
Next Post: [FIXED] android – How to set SSL pinning using retrofit for Firebase Realtime Database Url?

Related Posts

[FIXED] android – Get filenames for results returned from ActivityResultContracts.OpenMultipleDocuments() contract Android
[FIXED] java – How to fix this problem cannot resolve method startResultActivity com.google.zxing.Result? Android
[FIXED] android – Unable to get current (real time) location using FusedLocationProviderClient Android
[FIXED] android – How to change Retrofit baseUrl from shared preferences at runtime Android
[FIXED] android – Expecting member declaration for BroadcastReceiver Android
[FIXED] android – Update activity data (Data from cumming form server) without refresh activity Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is the rising action in Julius Caesar?
  • How do you secure a rope to itself?
  • Does waterproof laminate scratch easily?
  • What makes a building prewar?
  • What can you learn in a month without alcohol?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme