Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the arrow color material ExposedDropdownMenu / TextInputLayout

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.

like image 264
maghfirzakir Avatar asked May 01 '20 08:05

maghfirzakir


3 Answers

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>
like image 141
Gabriele Mariotti Avatar answered Nov 17 '22 05:11

Gabriele Mariotti


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>
like image 37
txusms Avatar answered Nov 17 '22 04:11

txusms


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>

like image 1
Emmanuel Njorodongo Avatar answered Nov 17 '22 03:11

Emmanuel Njorodongo