Search code examples
androidandroid-edittextandroid-alertdialogmaterial-components-androidandroid-textinputlayout

How to change EditText style in AlertDialog?


I added Cyanea (a theme engine) into my app and the EditText style changed (see images, color doesn't matter. The first picture is how it looks now, and the second one is what I want the dialog to look like). How can I change old EditText style back?

enter image description here

My code:

dialog_input.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingBottom="4dp"
    android:paddingTop="16dp">

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

        <EditText
            android:id="@+id/subj_name_input_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:text="Hello, World!"
            android:hint="@string/subject_name_dialog_hint"
            android:inputType="text"
            android:maxLines="1"
            android:maxLength="32" />
    </com.google.android.material.textfield.TextInputLayout>
</FrameLayout>

Solution

  • Use the Widget.Design.TextInputLayout style:

       <com.google.android.material.textfield.TextInputLayout
            style="@style/Widget.Design.TextInputLayout"
    

    enter image description here