Search code examples
androidkotlinandroid-edittextandroid-appcompatandroid-button

What is default background for AppCompatEditText?


I want to know what is default background of AppCompatEditText because I want to use its as default background of my selector state in xml but now I still not know what is it default backgrounf of this view.

This is what I currently did

private val defaultBackground = background

......

override fun setEnabled(enabled: Boolean) {
    if(enabled) this.background = defaultBackground
    else this.background = null
}

Solution

  • The default style for an AppCompatEditText is Widget.AppCompat.EditText.
    Navigating through the styles you can find that the background is defined with:

    <item name="android:background">?attr/editTextBackground</item>
    

    Looking for this attribute in the appcompat theme you can find:

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