Vji Vji - 4 months ago 10
Android Question

Center the layout after hiding the Android button programmatically

I have one LinearLayout and it is center_horizontal.

It contains three buttons: left, middle and right. All were fixed in same row.

When I hide the right button programmatically it will hide the button, but not center the left and middle buttons.

I want the left and middle buttons to be centered in the layout when I am hiding the right button. Is this possible?

Answer

Making a view invisible, makes it only invisible which has its effect.

Try using gone instead of invisible and you are done!