【问题标题】:What is default background for AppCompatEditText?AppCompatEditText 的默认背景是什么?
【发布时间】:2020-05-26 01:47:19
【问题描述】:

我想知道AppCompatEditText 的默认背景是什么,因为我想在 xml 中使用它作为我的选择器状态的默认背景,但现在我仍然不知道它是这个视图的默认背景。

这是我目前所做的

private val defaultBackground = background

......

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

【问题讨论】:

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


    【解决方案1】:

    AppCompatEditText 的默认样式是 Widget.AppCompat.EditText
    浏览样式,您会发现背景是这样定义的:

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

    在appcompat主题中寻找这个属性可以找到:

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

    【讨论】:

      猜你喜欢
      • 2013-01-08
      • 2011-12-24
      • 2011-06-07
      • 1970-01-01
      • 2013-11-09
      • 1970-01-01
      • 2023-01-22
      • 2012-02-03
      • 1970-01-01
      相关资源
      最近更新 更多