EditText Background

今天研究了一个EditText 为什么不同的主题下会显示不同的背景,例如是一个背景框或者一条下划线。

明显这是一个selector 不同造成的,那这个selector是在哪里定义的呢?

我们下面来看代码:

我们的manifest文件

1  android:theme="@style/Theme.AppCompat.Light.DarkActionBar">

在Theme.AppCompact.Light.DarkActionBar下面

1 <style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>

在Base.Theme.AppCompat.Light.DarkActionBar下面

<style name="Base.Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light">

在Base.Theme.AppCompat.Light下面

<style name="Base.Theme.AppCompat.Light" parent="Base.V7.Theme.AppCompat.Light">

终于发现了

<item name="editTextBackground">@drawable/abc_edit_text_material</item>

可以看到这个abc_edit_text_material就是一个selector ,以一条9.patch 的下划线为黑色的矩形作为背景。

同理,其它Theme 可以自己查了

原文地址:https://www.cnblogs.com/howarddeng/p/5373337.html