简体   繁体   中英

android animation make visible an item that i make invisible by code already

i have a button that is set to disappear at the activity start by this code:

againbtn.setVisibility(View.INVISIBLE);

inside another button i run this animation for my invisible button:

Animation anim3 = AnimationUtils.loadAnimation(MainActivity.this, R.anim.againbtnonanim);
anim3.setFillAfter(true);
againbtn.startAnimation(anim3);

when this animation runs, my invisible button appears!!! why is this so? I dont want this!what I want is first I make it visible and then it runs my animation, like this:

againbtn.setVisibility(View.VISIBLE);    
Animation anim3 = AnimationUtils.loadAnimation(MainActivity.this, R.anim.againbtnonanim);
anim3.setFillAfter(true);
againbtn.startAnimation(anim3);

but it doesn't work. My button appears without againbtn.setVisibility(View.VISIBLE); code and my animation is making it Invisible with this code: againbtn.setVisibility(View.INVISIBLE);, but this doesnt work as well.

with this siuation, when the button is invisible by an animation, it's click listener still works in that area!!! can someone please help me out?

Use android:visibility="gone" when you are done with the button click. It will be completely removed. The space used by that button can be reused. When you just say invisible you don't remove the button you just make it invisible. Its still there consuming that space.

also with your current code you could just use android your_button_name.setEnabled(false) so that the onclick does not work.

你可以试试这个

   againbtn.setVisibility(View.GONE); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM