Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between setVisibility() and setAlpha()

What is the difference between setVisibility(View.GONE) and setAlpha(0f)?

like image 569
baekacaek Avatar asked May 16 '13 18:05

baekacaek


2 Answers

setVisibility(View.GONE) will not only hide your view but it will also recycle the space occupied by this view. However setAlpha(0f) is equivalent to setVisibility(View.INVISIBLE) that only hides the view and still takes the space in your layout.

like image 66
Marcin S. Avatar answered Sep 27 '22 21:09

Marcin S.


setVisiblity(View.GONE) makes the View invisible:

This view is invisible, and it doesn't take any space for layout purposes.

setAlpha(0) just makes the View transparent, but it is still in the space and able to be interacted with.

Alpha docs: http://developer.android.com/reference/android/view/View.html#setAlpha(float)

Visibility docs: http://developer.android.com/reference/android/view/View.html#setVisibility(int)

like image 41
TronicZomB Avatar answered Sep 27 '22 21:09

TronicZomB