android - AppCompatEditText 的默认背景是什么?

标签 android kotlin android-edittext android-appcompat android-button

我想知道 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/

相关文章:

android - 从以字符串形式存储在 sqlite android 中的数据中获取月份

java - retrofit / Dagger - Android : Fatal Exception: API declarations must be interfaces

kotlin - 使用 SearchView 过滤 RecyclerView/ListAdapter

android - 当我尝试从中获取数据时,ViewModel 返回清晰的对象

android - 更改editText提示的字体

android - 为什么我的 EditText 复制/粘贴菜单在 EditText 下?如何更改弹出窗口的 z 顺序?

java - 安卓聊天客户端

android - 如何更新 Android 应用程序小部件的 UI

kotlin - 如何从 Repository > ViewModel > Fragment 传播 Livedata

Android错误膨胀类EditText