Skip to content

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

@Jumman04

Description

@Jumman04

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:

Output.mp4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions