material-components / material-components-android

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

[TextInputLayout] Unable to Style a Dropdown menu #1753

Closed GuanacoDevs closed 4 years ago

GuanacoDevs commented 4 years ago

Description: I'm trying to set a DropDown menu. But the dropdown Icon seems to be on top of the TextInputLayout, not to mention that I can not give a color to the dropdown arrow. The Hint when collapsed keeps what I think is the colorSurface attribute of my theme. In the layout editor the TextInputLayout seems ok but it does not look the same in my physical device as shown in the screenshots. My issues are the dropdown arrow covering the TextInputLayout and the background of the hint when collapsed, for the hint when collapsed tried to set a style for it with a transparent background but still the same.

Before selecting the dropdown arrow: Screenshot_20200924-204056_Escner Alcalda

When the dropdown list is displayed: Screenshot_20200924-204104_Escner Alcalda

After a selection has been made: Screenshot_20200924-204114_Escner Alcalda

Expected behavior: This is how it looks in the Layout Editor: screenshot_window

Source code: The main theme of my application inherits from: Theme.MaterialComponents.NoActionBar This is the TextInputLayout in my layout:

    <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/account_department_container"
            style="@style/account_text_input_layout"
            android:layout_marginTop="@dimen/eight_dip"
            android:hint="@string/department"
            app:layout_constraintBottom_toTopOf="@+id/button_google"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/account_user_name">

            <com.google.android.material.textfield.MaterialAutoCompleteTextView
                android:id="@+id/account_department"
                style="@style/account_auto_complete_text_view"
                tools:text="Desarrollo Comunal" />
        </com.google.android.material.textfield.TextInputLayout>

This are the corresponding styles:

    <style name="account_auto_complete_text_view" parent="Widget.MaterialComponents.AutoCompleteTextView.OutlinedBox.Dense">
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">@dimen/two_forty_dip</item>
        <item name="android:textColor">@color/teal_800</item>
        <item name="android:textSize">@dimen/fourteen_sip</item>
    </style>

    <style name="account_text_input_layout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu">
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_marginBottom">@dimen/null_dimen</item>
        <item name="android:layout_marginLeft">@dimen/eight_dip</item>
        <item name="android:layout_marginRight">@dimen/eight_dip</item>
        <item name="android:layout_marginTop">@dimen/eight_dip</item>
        <item name="android:textColorHint">@color/blue_grey_300</item>
        <item name="boxBackgroundColor">@android:color/white</item>
        <item name="boxStrokeColor">@color/amber_500</item>
        <item name="hintTextColor">@color/amber_500</item>
    </style>

Android API version: Android 10 & Android 7.1.1

Material Library version: implementation 'com.google.android.material:material:1.2.1'

Device: Samsung A71 & Xperia Z5P

GuanacoDevs commented 4 years ago

As it turns out I had set a color in my Dialog android:background, and that made the arrow looked covering the box. Still the hint when collapsed has a background, not transparent.