【问题标题】:How to color the EditText focus color for API < 21?如何为 API < 21 的 EditText 焦点颜色着色?
【发布时间】:2019-05-07 07:52:36
【问题描述】:

我有 EditTexts,他们用原色为底线着色 see here

我想让它保持黑色,所以我在我的布局中设置了 EditText:

android:backgroundTint="@android:color/black"

这很好用,但我将 minSDK 设置为 19。所以我立即收到警告说这不适用于 API

我该如何解决 API 19 和 API 20 的问题?

【问题讨论】:

    标签: android android-edittext android-api-levels


    【解决方案1】:

    我使用了这样的代码,它对我有用:

    yourEditText.getBackground().setColorFilter(getResources().getColor(android.R.color.black), PorterDuff.Mode.SRC_IN);

    希望对你有用

    【讨论】:

    • 我宁愿使用:editText.getBackground().setColorFilter(Color.BLACK,PorterDuff.Mode.SRC_IN);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 2012-03-02
    相关资源
    最近更新 更多