简体   繁体   English

Android Material重新着色EditText下划线

[英]Android Material recolor EditText underline

how can I recolor the underline of an EditText in android 5.0 (Material) ? 如何在android 5.0(Material)中重新着色EditText的下划线? It is appearing gray but I want it to be blue, how can I archieve that? 它看起来很灰,但我希望它是蓝色的,我怎么能达到这个目的呢?

you have to set in your app Theme this line: 你必须在你的应用主题中设置这一行:

    <item name="android:colorControlActivated">#123490</item>

(or colorAccent for wider range of coloring) (或colorAccent用于更广泛的着色)

more about new Material xml styles params HERE . 更多关于新材料xml样式params HERE you should also define colorPrimary and colorPrimaryDark 你还应该定义colorPrimarycolorPrimaryDark

以编程方式执行: editText.getBackground().setColorFilter(getResources().getColor(android.R.color.white), PorterDuff.Mode.SRC_ATOP);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM