AppCompat and EditText different underline on different API

一笑奈何 提交于 2019-11-30 14:03:34

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>

You should not change the background. It's better if you create a theme, and use theme colors (colorPrimary, colorAccent are the most important for widgets) to get the desired effect. Assign the theme to your EditText and enjoy. Note: you should use one of the AppCompat theme as base theme.

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorAccent">@color/accent</item>
</style>

and in your colors.xml

<color name="primary">#ff0000</color>
<color name="accent">#00ff00</color>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!