<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_welcome_root"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
tools:context="${relativePackage}.${activityClass}" >
<ProgressBar
android:id="@+id/pb_welcome_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:indeterminateDrawable="@anim/image_progress"
android:indeterminateDuration="700"/>
<TextView
android:id="@+id/tv_welcome_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@id/pb_welcome_loading"
android:layout_marginBottom="10dp"
android:text="当前版本: 1.0"
android:textSize="20sp" />
</RelativeLayout>
image_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progess" >
</rotate>
public class WelcomeActivity extends Activity {
private RelativeLayout rl_welcome_root;
private Handler handler = new Handler(){
public void handleMessage(android.os.Message msg) {
if(msg.what==1) {
startActivity(new Intent(WelcomeActivity.this, SetupGuide1Activity.class));
//关闭自己
finish();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
rl_welcome_root = (RelativeLayout) findViewById(R.id.rl_welcome_root);
//显示动画
showAnimation();
//发送延迟3s的消息
handler.sendEmptyMessageDelayed(1, 3000);
}
/**
* 显示动画
*
* 旋转动画 RotateAnimation: 0-->360 视图的中心点 2s
* 透明度动画 AlphaAnimation: 0-->1 2s
* 缩放动画 ScaleAnimation: 0-->1 视图的中心点 2s
*/
private void showAnimation() {
//旋转动画 RotateAnimation: 0-->360 视图的中心点 2s
RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setDuration(2000);
//透明度动画 AlphaAnimation: 0-->1 2s
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
alphaAnimation.setDuration(2000);
//缩放动画 ScaleAnimation: 0-->1 视图的中心点 2s
ScaleAnimation scaleAnimation = new ScaleAnimation(0, 1, 0, 1,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(2000);
//创建复合动画,并添加
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(rotateAnimation);
animationSet.addAnimation(alphaAnimation);
animationSet.addAnimation(scaleAnimation);
//启动
rl_welcome_root.startAnimation(animationSet);
}
}