android应用启动加载动画页面
2014-11-27 10:18
555 查看
1、当你打开一个应用程序时,会看到前面有一个加载动画页面,看看怎么来实现
2、新建一个.xml 文件,添加一个ImageView 组件
<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/welcome_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
3、创建一个Activity
package com.example.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView welcomeImg = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
welcomeImg = (ImageView) this.findViewById(R.id.welcome_img);
AlphaAnimation anima = new AlphaAnimation(0.3f, 1.0f);
anima.setDuration(3000);// 设置动画显示时间
welcomeImg.startAnimation(anima);
anima.setAnimationListener(new AnimationImpl());
}
private class AnimationImpl implements AnimationListener {
@Override
public void onAnimationStart(Animation animation) {
welcomeImg.setBackgroundResource(R.drawable.welcome);
}
@Override
public void onAnimationEnd(Animation animation) {
skip(); // 动画结束后跳转到别的页面
}
@Override
public void onAnimationRepeat(Animation animation) {
}
}
private void skip() {
startActivity(new Intent(this, OtherActivity.class));
finish();
}
}
2、新建一个.xml 文件,添加一个ImageView 组件
<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/welcome_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
3、创建一个Activity
package com.example.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView welcomeImg = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
welcomeImg = (ImageView) this.findViewById(R.id.welcome_img);
AlphaAnimation anima = new AlphaAnimation(0.3f, 1.0f);
anima.setDuration(3000);// 设置动画显示时间
welcomeImg.startAnimation(anima);
anima.setAnimationListener(new AnimationImpl());
}
private class AnimationImpl implements AnimationListener {
@Override
public void onAnimationStart(Animation animation) {
welcomeImg.setBackgroundResource(R.drawable.welcome);
}
@Override
public void onAnimationEnd(Animation animation) {
skip(); // 动画结束后跳转到别的页面
}
@Override
public void onAnimationRepeat(Animation animation) {
}
}
private void skip() {
startActivity(new Intent(this, OtherActivity.class));
finish();
}
}
相关文章推荐
- iOS应用自定义启动加载页面(launch image)的命名规则详述
- android应用启动页面显示
- Android自定义一个简单的动画加载页面
- Android实现3D页面加载进度条动画
- android应用启动页面
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- android 应用的loading加载动画制作(闪屏)
- Android应用之——仿美团loading加载中动画
- Android实战页面内容加载动画
- android应用启动画面+activity动画
- Android应用之——仿美团loading加载中动画
- 【Android】应用的loading加载动画制作
- Android AnimationDrawable动画与APP启动引导页面
- android应用加载过程中的loading动画
- android自定义字体和程序启动时的加载页面
- Android应用之——仿美团loading加载中动画
- android应用的loading加载动画制作
- Android 应用中启动其他应用 && 在页面中寻找其他页面的控件
- android 解决启动页面加载图片空白以及去掉标题栏
- Android实战页面内容加载动画