布局xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView_loadint_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/animation"/>
</RelativeLayout>
设置广告展示的内容
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="@drawable/web_loading_1" android:duration="100" />
<item android:drawable="@drawable/web_loading_2" android:duration="100" />
<item android:drawable="@drawable/web_loading_3" android:duration="100" />
</animation-list>
Activity中设置播放的时间 及跳转的页面
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;
public class MainActivity extends Activity {
AnimationDrawable anim;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView image=(ImageView) findViewById(R.id.imageView_loadint_1);
anim=(AnimationDrawable) image.getBackground();
anim.start();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
startActivity(new Intent(MainActivity.this,SecondActivity.class));
}
}, 6000);
}
}