What is the difference between ImageView.setBackgroundResource and ImageView.setImageResource?

后端 未结 4 1309
故里飘歌
故里飘歌 2020-12-05 14:10

I have seen these different approaches in setting images but I don\'t get the difference.

Why there two methods?

4条回答
  •  一个人的身影
    2020-12-05 14:55

    SetBackdroundResource is for a drawable or color you want to set at the background of the imageview and your setImageResource is like to display on it.

    so setImageResource is for add any resource to your imageview's front side. try this example and look at the difference. Android Gallery, ImageView Example . This is a two layer effect,backside (setBackgroundResource) and frontside (setImageResource).

提交回复
热议问题