我想知道 AppCompatEditText
的默认背景是什么,因为我想将其用作 xml 中选择器状态的默认背景,但现在我仍然不知道该 View 的默认背景是什么。
这就是我目前所做的
private val defaultBackground = background
......
override fun setEnabled(enabled: Boolean) {
if(enabled) this.background = defaultBackground
else this.background = null
}
最佳答案
AppCompatEditText
的默认样式是 Widget.AppCompat.EditText
。
浏览样式,您可以发现背景是通过以下方式定义的:
<item name="android:background">?attr/editTextBackground</item>
在 appcompat 主题中查找此属性,您可以找到:
<item name="editTextBackground">@drawable/abc_edit_text_material</item>
关于android - AppCompatEditText 的默认背景是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62013376/