AppCompat和EditText上强调不同的API [英] AppCompat and EditText underline on different API

查看:1250
本文介绍了AppCompat和EditText上强调不同的API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让下划线线条颜色变化的EditText(验证,所以它必须能够在运行时更改)。我使用AppCompat做到这一点。问题是,在API> = 21,我看到的不是加粗版透明黑线(灰覆盖)。

I'm trying to make underline line color change for EditText (validation, so it must be able to change in runtime). I'm using AppCompat to do it. The problem is that on API >= 21, 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>

这篇关于AppCompat和EditText上强调不同的API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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