0

我有一个我想慢慢淡入的图像;我玩过标准动画结构,但它似乎从来没有工作过。

(图片代码:)

@Override
    public void draw(Canvas c, Layer layer) {
        if ( layer == Layer.BACKGROUND ) {              

            Animation a = new AlphaAnimation(1.00f, 0.00f);
            a.setDuration(4000);

            instructions.startAnimation(a);

            location.left = (view.getWidth() - instructions.getMinimumWidth() ) /2;
            location.right = location.left + instructions.getMinimumWidth();
            location.top = view.getHeight() / 2;
            location.bottom = location.top + instructions.getMinimumHeight();
            instructions.setBounds(location);
            instructions.draw(c);
        }
        //explosions.draw(c, layer);
    }
};

...“对于 BitmapDrawable 类型,startAnimation 是未定义的,”它说。

4

2 回答 2

0

startAnimation是 a 的一个方法,View所以如果你在一个ImageView实例中有位图imageView,你应该调用imageView.startAnimation(a);.

于 2012-05-06T08:08:38.060 回答
0

与其在代码中进行,不如考虑使用 XML:http: //developer.android.com/guide/topics/resources/animation-resource.html#View

于 2012-05-06T08:13:07.060 回答