ImageView Visibility Issue in Relative Layout

五迷三道 提交于 2020-01-14 04:18:10

问题


I've seen all sorts of code that makes me think that mine should work, but for some reason it does not. I've got an ImageView that animates vertically down another image and I want the mobile imageview to disappear once the animation is complete but it does not. The 'scanbar' imageview is the one in question. it is set as invisible in the XML and is made visible on a button press. I need it to go away when the animation is finished.

public class scan extends Activity {

EditText Quote;
private static final Random rgenerator = new Random();
ImageView scanbar;
public void scanLine()  {
    // Displays the scanline animation over the wireframe image


    ImageView wireframe;
    scanbar = (ImageView)findViewById(R.id.scanbar);
    wireframe = (ImageView) findViewById(R.id.wireframe);
    scanbar.setVisibility(View.VISIBLE);
    // Super ultra-secret code

}
Animation.AnimationListener scanListener = new Animation.AnimationListener() {

    @Override
    public void onAnimationStart(Animation animation) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onAnimationRepeat(Animation animation) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onAnimationEnd(Animation animation) {
        // TODO Auto-generated method stub
        scanbar.setVisibility(View.INVISIBLE);
        setResults();
    }
};

The setResults(); call works properly, so I know that section of code is being executed. Anyone know what I'm doing wrong?


回答1:


Will give this old question an answer just in case someone stumbles upon it like me.

Check out stickupkid's answer here: Android, setVisbility to gone not working in RelativeLayout. Call clearAnimation() on what ever view is doing the animation before calling View.INVISIBLE




回答2:


I can confirm that: Calling clearAnimation() on the view that is doing the animation before calling View.INVISIBLE, or GONE does the trick.



来源:https://stackoverflow.com/questions/6515470/imageview-visibility-issue-in-relative-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!