更改箭头颜色材质 ExposedDropdownMenu / TextInputLayout

mag*_*kir 4 android material-design android-textinputlayout material-components material-components-android

我想将箭头颜色更改为白色。 怎么做? 这是我的代码

我想将箭头颜色更改为白色。怎么做?这是我的代码

<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>
Run Code Online (Sandbox Code Playgroud)

这是我的风格:

<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>
Run Code Online (Sandbox Code Playgroud)

我希望很清楚。提前致谢。

Gab*_*tti 14

您可以app:endIconTint在布局中使用该属性:

 <com.google.android.material.textfield.TextInputLayout
            ...
            app:endIconTint="@color/my_selector_color">
Run Code Online (Sandbox Code Playgroud)

或者您可以使用自定义样式:

 <com.google.android.material.textfield.TextInputLayout
    style="@style/ExposedDropdownMenu"
    ...>
Run Code Online (Sandbox Code Playgroud)

和:

  <style  name="name="ExposedDropdownMenu" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
    <item name="endIconTint">@color/my_selector_color</item>
  </style>
Run Code Online (Sandbox Code Playgroud)


小智 6

如果你想改变drawable,而不仅仅是颜色,你可以设置endIconDrawable。对于drawable,放置一个像这样的选择器xml:

    <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>
Run Code Online (Sandbox Code Playgroud)