布局:
<ImageView
android:id="@+id/dongman"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:src="@drawable/kaiqi" />
代码:
public class dongman extends Activity{
private ImageView welcomeImg = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dongman); //我的布局的名字
welcomeImg = (ImageView) this.findViewById(R.id.dongman); //控件
AlphaAnimation anima = new AlphaAnimation(0.3f, 1.0f); //动漫相关的类
anima.setDuration(3000);// 设置动画显示时间
welcomeImg.startAnimation(anima); //welcomeimg(ImageView控件名)启动动画(动画);这里是设置为启动动画的关键
anima.setAnimationListener(new AnimationImpl()); //动画设置监听
}
private class AnimationImpl implements AnimationListener { //这里继承了动画监听的类
@Override
public void onAnimationStart(Animation animation) {
// welcomeImg.setBackgroundResource(R.drawable.ic_launcher); 这里是设置背景图片的
}
@Override
public void onAnimationEnd(Animation animation) {
skip(); // 动画结束后跳转到别的页面
}
@Override
public void onAnimationRepeat(Animation animation) { //这里设置动画的重复
}
}
private void skip() {
startActivity(new Intent(this, main.class));
finish();
}
}
然后将这个类设置为主类就可以使用的