Luke Batley
Luke Batley

Reputation: 2402

changing visibility of text android

Hi i have two textViews that i initially set its visibility to gone then animate in and become visible. now i want to make the invisible again but for some reason they're still showing on screen does anyone no why?

in my onCreate() i make the view gone

register = (TextView)findViewById(R.id.register);
        register.setVisibility(View.GONE);
        forgotpassword = (TextView)findViewById(R.id.forgotpw);
        forgotpassword.setVisibility(View.GONE); 

then later on i make it visible

public void run() 
            {
               animations();
               loginForm.setVisibility(View.VISIBLE);
               register.setVisibility(View.VISIBLE);
               forgotpassword.setVisibility(View.VISIBLE);
            }

and then when a user presses a button i want the text views to become invisible so that they retain their layout but they stay visible on screen

signInBtn = (Button) findViewById(R.id.signin);
        signInBtn.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                signInProcess();
            }
        });


 public void signInProcess() { 

     register.setVisibility(View.INVISIBLE);
     forgotpassword.setVisibility(View.INVISIBLE);
     setuploader.setVisibility(View.VISIBLE);

}

Upvotes: 0

Views: 141

Answers (1)

Ahmed Aeon Axan
Ahmed Aeon Axan

Reputation: 2139

In Android when you animate something, It's just drawn somewhere else. The actual element is not moved. So when you animate signInBtn it's drawn somewhere else, but the actual button is not moved from the original position. So when you click the button the click handler is not called.

To avoid this set fillAfter = True in your animation so the button will actually get moved at the end of your animation.

Also, after animating a view in Android make sure you call View.clearAnimation() before trying to change its visibility.

Upvotes: 1

Related Questions