[英]Animation on showing up in android
I am trying to perform animation on 4 png images. 我正在尝试对4个png图像执行动画。 I have
drawable
folder in res
folder,containing the images to be animated and one animation.xml
我在
res
文件夹中有drawable
文件夹,其中包含要动画的图像和一个animation.xml
Now my problem is that:when I say animation.start
I cannot see anything on the emulator 现在我的问题是:当我说
animation.start
时,我在模拟器上看不到任何东西
my code: 我的代码:
package com.androcles.TreeActivity;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class TreeActivity extends Activity {
private ImageView image1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tree);
image1 = (ImageView)findViewById(R.id.imageView1);
image1.setImageBitmap(null);
image1.setBackgroundResource(R.drawable.animation);
final AnimationDrawable mailAnimation = (AnimationDrawable) image1.getBackground();
image1.post(new Runnable() {
public void run()
{
if ( mailAnimation != null )
{
System.out.println("Before Animation Starts...!!!!!");
mailAnimation.start();
System.out.println("After Animation Starts...!!!!!");
}
}
});
}
}
Try this way: 尝试这种方式:
m_animation = AnimationUtils.loadAnimation( getApplicationContext(), R.anim.alpha_animation); m_ivImage.startAnimation(m_animation);
Try with these codes. 尝试使用这些代码。
View view;
view=(Button)findViewById(R.id.continue_but); // may be image or some thing
Animation hyperspaceJump = AnimationUtils.loadAnimation(AppActivity.this, R.anim.slide_left);
view.startAnimation(hyperspaceJump);
view.setVisibility(View.VISIBLE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.