【问题标题】:ImageView Visibility Issue in Relative Layout相对布局中的 ImageView 可见性问题
【发布时间】:2011-09-24 19:41:45
【问题描述】:

我见过各种各样的代码,让我认为我的应该可以工作,但由于某种原因它不能。我有一个 ImageView 可以垂直向下动画另一个图像,我希望移动图像视图在动画完成后消失,但它不会。 'scanbar' imageview 是有问题的。它在 XML 中设置为不可见,并且在按下按钮时可见。我需要它在动画完成后消失。

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();
    }
};

setResults(); call 工作正常,所以我知道那段代码正在执行。有谁知道我做错了什么?

【问题讨论】:

  • 你的动画帧使用什么?
  • 这是一个翻译动画,将图像从帧的顶部移动到底部

标签: android visibility android-relativelayout


【解决方案1】:

我可以确认:在调用 View.INVISIBLE 或 GONE 之前对正在执行动画的视图调用 clearAnimation() 即可。

【讨论】:

    【解决方案2】:

    会给这个老问题一个答案,以防有人像我一样偶然发现它。

    在此处查看stickupkid 的答案:Android, setVisbility to gone not working in RelativeLayout。在调用 View.INVISIBLE 之前,调用 clearAnimation() 了解正在执行动画的视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多