How to remove ImageButton's standard background image?

前端 未结 10 1511
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 01:50

In ImageButton I want to remove the standard button background image. In http://developer.android.com it is said, that one must define his\\her own background i

10条回答
  •  青春惊慌失措
    2020-12-13 01:52

    Using Kotlin, you can do this:

    val myImageButton = ImageButton(context).apply({
        background = null
    
        // and if you need to add drawable, simply use:
    
        setImageDrawable(ContextCompat.getDrawable(context, 
                             R.drawable.ic_save_black_24px))
    })
    

提交回复
热议问题