setBackgroundDrawable() deprecated

前端 未结 11 1659
长发绾君心
长发绾君心 2020-12-03 00:18

So my sdk goes from 15 to 21 and when I call setBackgroundDrawable(), Android Studio tells me that it\'s deprecated.

I thought of going around it using:

11条回答
  •  囚心锁ツ
    2020-12-03 01:08

    //Java
    view.setBackground(ActivityCompat.getDrawable(context, R.drawable.bg))
    
    //Kotlin 
    view.background = ActivityCompat.getDrawable(context, R.drawable.bg)
    

提交回复
热议问题