我有一个普通的EditText
字段,我希望在程序中可以更改下划线的颜色。
<EditText
android:id="@+id/edit_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
其他答案建议像这样更改背景颜色过滤器:
editText.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
然而,当我运行应用程序时,我没有看到任何变化。仅仅改变了背景本身:
editText.setBackground(color)
如何以编程方式更改EditText
、AppCompatEditText
或TextInputEditText
的下划线颜色?我正在使用Support Library的25.0.1版本。
EditText
整体变为color
-这不是我想要的!