【问题标题】:What style attribute do I use to change the color of an EditText's focused bottom line?我使用什么样式属性来更改 EditText 的焦点底线的颜色?
【发布时间】:2015-04-01 20:38:42
【问题描述】:

我正在尝试以我的风格从焦点 EditText 更改底线的颜色。

当我开始编辑文本时,appcompat.Light 中底线的颜色变为蓝绿色。我想知道这种颜色来自什么属性。

我也支持 API 14,所以我不能使用色调。

【问题讨论】:

标签: java android android-layout android-edittext android-styles


【解决方案1】:

您可以在 xml 中使用此行更改此颜色:

android:backgroundTint="@color/blue"

您可以在代码中更改它,例如:

editText.getBackground().setColorFilter(getResources().getColor(R.color.blue), PorterDuff.Mode.SRC_ATOP);

您还可以通过在您的主题.xml 文件中将此行添加到您的样式中来更改应用程序中的任何位置:

<item name="colorControlActivated">@color/blue</item>

【讨论】:

  • 这些都需要最少的 API 21,因为它是第一个以这种方式为小部件着色
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-21
  • 1970-01-01
  • 2019-10-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多