在不同的API应用程序兼容性和不同的EditText下划线 [英] AppCompat and EditText different underline on different API

查看:205
本文介绍了在不同的API应用程序兼容性和不同的EditText下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做出的EditText 下划线线的颜色变化(这将用于输入的验证,因此它必须能够在运行时改变)。

I'm trying to make underline line color change for EditText (it will be used for input's validation, so it must be able to change in runtime).

我使用的应用程序兼容性库。的问题是,有关API 21以上,我看到的代替粗体版本透明黑线(灰色覆盖),

I'm using AppCompat library. The problem is that on API 21 and above, I see transparent black line (gray overlay), instead of bolded version.

如何使它等同于API 16?

How to make it the same as in API 16?

我用这个code改变色调:

I used this code to change tint:

    final Drawable originalDrawable = view.getBackground();
    final Drawable wrappedDrawable = DrawableCompat.wrap(originalDrawable);
    DrawableCompat.setTint(wrappedDrawable, Color.RED);
    setBackground(view,wrappedDrawable);

推荐答案

解决方案通过将这些行到我的主题找到:

Solution found by adding these lines to my theme:

    <item name="editTextStyle">@style/Base.V7.Widget.AppCompat.EditText</item>
    <item name="editTextBackground">@drawable/abc_edit_text_material</item>

这篇关于在不同的API应用程序兼容性和不同的EditText下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆