【问题标题】:Can I get the default hint color of an EditText?我可以获得 EditText 的默认提示颜色吗?
【发布时间】:2014-04-24 14:00:06
【问题描述】:

有没有办法从 EditText 中获取提示颜色?

我也需要颜色设置为 EditText 的文本颜色

【问题讨论】:

  • 你应该能够分辨出提示的颜色,然后用它来设置你的 textColor 属性!

标签: android colors android-edittext hint


【解决方案1】:

您可以使用getHintTextColors() API。检查this 文档。

【讨论】:

    【解决方案2】:

    我猜你可以用这个:

    final ColorStateList colors = editText.getHintTextColors();
    editText.setTextColor(colors);
    

    请注意,提示颜色实际上是ColorStateList

    【讨论】:

      【解决方案3】:

      延迟响应(但值得)。您可以使用:

      <EditText
          ...
          android:textColor="?android:attr/textColorHint" />
      

      【讨论】:

        猜你喜欢
        • 2017-11-11
        • 2014-11-09
        • 1970-01-01
        • 1970-01-01
        • 2012-11-09
        • 1970-01-01
        • 1970-01-01
        • 2014-01-28
        • 2011-05-26
        相关资源
        最近更新 更多