Search code examples
javaandroidcolorsandroid-textinputlayoutmaterial-components-android

Android: Change hint text color for a material exposed outlined drop-down when unfocused


I am trying to change the hint color of a material exposed dropdown when its not selected or unfocused. I am unable to find the exact method that can do this. I have been able to change pretty much everything according to my liking except that. Can somebody help me with this?

Active State

Inactive State


Solution

  • You can use the android:textColorHint attribute:

        <com.google.android.material.textfield.TextInputLayout
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
            android:textColorHint="@color/text_input_hint_selector"
            ...>
    

    with this selector:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:alpha="0.38" android:color="@color/...." android:state_enabled="false"/>
        <item android:alpha="0.6" android:color="@color/...."/>
    </selector>
    

    enter image description here enter image description here