3

Using this answer as a reference, I understand that a View's setAlpha(float) basically draws the view normally on a buffer, then uses a 2nd pass to draw the view with the alpha value on the scene, and because of this, setting a View's alpha usually involves harming the performance of the app.

However, ImageViews have another method called setImageAlpha(int) which, from what I've gathered, applies the alpha value on the ImageView's colour filter - removing the need for a 2nd pass all together and is therefore much more efficient.

My question is - since using setImageAlpha on an ImageView is much more efficient, is there any reason to ever use setAlpha(float) on an ImageView? Or should this be avoided in general in favour for setImageAlpha(int)?

Community
  • 1
  • 1
Gil Moshayof
  • 16,633
  • 4
  • 47
  • 58

1 Answers1

3

From the literal meaning of the methods, I guess setImageAlpha sets the image's alpha only. If the image view has a background, the background would not be translucent. But setAlpha sets the whole view's alpha value.

Sweeper
  • 213,210
  • 22
  • 193
  • 313