0

I have two textviews and one button. The first textview is to get user email address, once user clicks on the send button, it sends him a pin number. initially pin number textview is invisible, if pin number is sent to email address and then it becomes visible.

My question why there is space a between the first textview and the button, because of initially pin textview invisible. I though that it automatically aligns when the pin textview becomes visible. Why it still holds its place. I wonder how could I solve that issue?

editTextEmail = (EditText) view.findViewById(R.id.editTextEmail);
editTextPin = (EditText) view.findViewById(R.id.editTextPin);                                      
editTextPinLayout =(TextInputLayout) view.findViewById((R.id.editTextPinInputLayout));
editTextPinLayout.setVisibility(View.INVISIBLE);
buttonSend = (Button) view.findViewById(R.id.buttonSend);
casillas
  • 16,351
  • 19
  • 115
  • 215

2 Answers2

1

View.GONE that would hide it altogether and remove the space. Once you have the response do View.VISIBLE

Dhinakaran Thennarasu
  • 3,336
  • 4
  • 26
  • 39
1

You should call View.GONE instead of View.INVISIBLE

setVisibility(View.INVISIBLE)

This view is invisible, but it still takes up space for layout purposes.

setVisibility(View.GONE)

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

Finally

editTextPinLayout.setVisibility(View.GONE);
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198