更改箭头颜色 material ExposedDropdownMenu / TextInputLayout
Changing the arrow color material ExposedDropdownMenu / TextInputLayout
我想将箭头颜色更改为白色。怎么做?这是我的代码
<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>
这是我的风格:
<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>
我希望一切都清楚。提前致谢。
您可以在布局中使用app:endIconTint
属性:
<com.google.android.material.textfield.TextInputLayout
...
app:endIconTint="@color/my_selector_color">
或者您可以使用自定义样式:
<com.google.android.material.textfield.TextInputLayout
style="@style/ExposedDropdownMenu"
...>
与:
<style name="name="ExposedDropdownMenu" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
<item name="endIconTint">@color/my_selector_color</item>
</style>
只需使用
将 endIconTint 属性添加到 TextInputLayout
app:endIconTint="@color/primaryDarkColor"
哪里
@color/primaryDarkColor
是您想要的颜色选择
下面的示例带有完整的 XML 代码
<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>
如果你想改变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>
我想将箭头颜色更改为白色。怎么做?这是我的代码
<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>
这是我的风格:
<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>
我希望一切都清楚。提前致谢。
您可以在布局中使用app:endIconTint
属性:
<com.google.android.material.textfield.TextInputLayout
...
app:endIconTint="@color/my_selector_color">
或者您可以使用自定义样式:
<com.google.android.material.textfield.TextInputLayout
style="@style/ExposedDropdownMenu"
...>
与:
<style name="name="ExposedDropdownMenu" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
<item name="endIconTint">@color/my_selector_color</item>
</style>
只需使用
将 endIconTint 属性添加到 TextInputLayoutapp:endIconTint="@color/primaryDarkColor"
哪里
@color/primaryDarkColor
是您想要的颜色选择
下面的示例带有完整的 XML 代码
<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>
如果你想改变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>