material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.09k stars 3.03k forks source link

[MaterialAlertDialogBuilder] Automatic resizing of MaterialAlertDialogBuilder height when the keyboard is open #4039

Open Jumman04 opened 5 months ago

Jumman04 commented 5 months ago

Description: I have built a custom dialog with MaterialAlertDialogBuilder. The dialog has 2 TextInputLayouts. The problem is when I try to write something in the TextInputEditText and when the keyboard is visible, the MaterialAlertDialogBuilder shrinks in height.

Expected behavior: I want to prevent automatic resizing of MaterialAlertDialogBuilder height when the keyboard is open.

Source code: In XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content"
    android:orientation="vertical"
    android:padding="16dp"
    tools:viewBindingIgnore="true">

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="দোয়া"
        app:endIconMode="clear_text"
        app:shapeAppearance="@style/ShapeAppearance.App.SmallComponent"
        tools:viewBindingIgnore="true">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/doarName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </com.google.android.material.textfield.TextInputLayout>

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="11dp"
        android:hint="দৈনিক কতবার পাঠ করবেন?"
        app:endIconMode="clear_text"
        app:shapeAppearance="@style/ShapeAppearance.App.SmallComponent"
        tools:viewBindingIgnore="true">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/number"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="number" />

    </com.google.android.material.textfield.TextInputLayout>

</LinearLayout>

In Kotlin:

MaterialAlertDialogBuilder(this@TosbiActivity).setView(view).setTitle("দোয়া যুক্ত করুন")
                .setPositiveButton("Apply") { dialog, _ ->

                    /*
                    ......
                     */

                    dialog.dismiss()
                }.setNegativeButton("Cancel") { dialog, _ ->
                    dialog.dismiss()
                }.show()

Android API version: 33

Material Library version: 1.11.0

Device: Symphony i69, Display 5.7″ (1440 x 720 pixels)

Screen Record:

https://github.com/material-components/material-components-android/assets/113237846/33b14826-cb9d-459b-8ea3-85b1611ef89a

Jumman04 commented 5 months ago

I post on StackOverflow how to solve this bug. I've found several answers, though they fail to fully resolve.

link: https://stackoverflow.com/q/77411599/19610655

bubbleguuum commented 4 months ago

Try android:windowSoftInputMode="adjustNothing" in the Manifest on your Activity.

Jumman04 commented 4 months ago

@bubbleguuum Sorry for my late reply. I also tried this way, but doesn't work.

sarowarhosen03 commented 3 months ago

কিরে ভাই কোনো সমাধান হইল কি?