Changing the arrow color material ExposedDropdownMenu / TextInputLayout
P

3

12

I want to change the arrow color to white. how to do it? here's my code

I want to change the arrow color to white. how to do it? here's my code

<com.google.android.material.textfield.TextInputLayout
    style="@style/ExposedDropdownMenu"
    android:hint="Select"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <AutoCompleteTextView
        android:focusable="false"
        android:textSize="17sp"
        android:padding="15dp"
        android:textColorHint="@color/white"
        android:textColor="@color/white"
        android:id="@+id/actv_pool"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:ignore="LabelFor" />

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

here's my style:

<style name="ExposedDropdownMenu" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
    <item name="boxStrokeColor">#fff</item>
    <item name="boxStrokeWidth">1dp</item>
    <item name="android:textColorHint">#fff</item>
</style>

I hope it's clear. thanks in advance.

Purchasable answered 1/5, 2020 at 8:48 Comment(0)
L
32

You can use the app:endIconTint attribute in the layout:

 <com.google.android.material.textfield.TextInputLayout
            ...
            app:endIconTint="@color/my_selector_color">

or you can use a custom style:

 <com.google.android.material.textfield.TextInputLayout
    style="@style/ExposedDropdownMenu"
    ...>

with:

  <style  name="name="ExposedDropdownMenu" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
    <item name="endIconTint">@color/my_selector_color</item>
  </style>
Limewater answered 1/5, 2020 at 13:19 Comment(0)
P
6

If you want change drawable, not only color, you can set endIconDrawable. For drawable put a selector xml like this:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">

      <item android:drawable="@drawable/ic_page_up" android:state_checked="true"/>
      <item android:drawable="@drawable/ic_page_down"/>
    </selector>
Pike answered 19/5, 2021 at 13:44 Comment(1)
Do you know why the state is checked even though AutoCompleteTextView inherits from EditText and not from a CheckBox? Am I missing something to do with states?Esurient
H
2

Simply add endIconTint attribute to the TextInputLayout by using

app:endIconTint="@color/primaryDarkColor"

where

@color/primaryDarkColor

is your desired color of choice

Example below with full XML Code


        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/til_paying_bank"
            style = "@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/til_withdrawal_date"
            android:layout_centerHorizontal="true"
            android:padding="5dp"
            app:endIconTint="@color/primaryDarkColor">

            <AutoCompleteTextView
                android:id="@+id/actv_paying_bank"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/paying_bank"
                android:dropDownSelector="@color/primaryLightColor"
                />

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

Hugues answered 16/3, 2021 at 13:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.