我有一个图像,我想慢慢淡入;我已经尝试了标准的动画结构,但它似乎从未起作用。
(图像代码:)
@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);
}
};
。"startAnimation未定义BitmapDrawable类型,"它说。
> startAnimation
是View
的方法,所以如果你在ImageView
实例imageView
中有位图,你应该调用imageView.startAnimation(a);
。
不要在代码中执行此操作,请考虑使用 XML: http://developer.android.com/guide/topics/resources/animation-resource.html#View