Android:更改材质风格的下拉框在失去焦点时的提示文本颜色。

huangapple go评论76阅读模式
英文:

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

问题

我正在尝试更改material exposed dropdown未选中失去焦点时的提示文字颜色。我无法找到确切的方法来实现这个目标。除了这个之外,我已经成功地按照自己的喜好更改了几乎所有内容。是否有人可以帮助我解决这个问题?

英文:

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?

Android:更改材质风格的下拉框在失去焦点时的提示文本颜色。

Android:更改材质风格的下拉框在失去焦点时的提示文本颜色。

答案1

得分: 0

你可以使用 android:textColorHint 属性:

    <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
        android:textColorHint="@color/text_input_hint_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>

Android:更改材质风格的下拉框在失去焦点时的提示文本颜色。
Android:更改材质风格的下拉框在失去焦点时的提示文本颜色。

英文:

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>

Android:更改材质风格的下拉框在失去焦点时的提示文本颜色。
Android:更改材质风格的下拉框在失去焦点时的提示文本颜色。

huangapple
  • 本文由 发表于 2020年8月2日 22:24:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/63217111.html
  • android
  • android-textinputlayout
  • colors
  • java
  • material-components-android
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定