如何以编程方式更改TextInputEditText的行和提示颜色?

问题描述 投票:-1回答:1

1)从服务器获取颜色

2)比将TextInputEditText的行和提示更改为颜色(适用于所有州)

  • 我正在使用material:1.0.0 for androidx
android android-textinputlayout material-components material-components-android textinputlayout
1个回答
0
投票

要设置颜色,您可以使用:

// Sets the text color used by the hint in both the collapsed and expanded states
textInputLayout.setDefaultHintTextColor(...);

//Sets the collapsed hint text color
textInputLayout.setHintTextColor(....);

在FilledBox布局中更改下划线颜色,可以使用方法[[setBoxStrokeColor

setBoxStrokeColor(ContextCompat.getColor(this,R.color....));
您可以使用单色或类似的选择器:

<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="?attr/colorPrimary" android:state_focused="true"/> <item android:alpha="0.87" android:color="?attr/colorOnSurface" android:state_hovered="true"/> <item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_enabled="false"/> <item android:alpha="0.38" android:color="?attr/colorOnSurface"/> </selector>

© www.soinside.com 2019 - 2024. All rights reserved.