闪屏效果

1.Activity
public class SlapshActivity extends Activity {
    RelativeLayout Rlroot;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_slapsh);
        
        Rlroot=(RelativeLayout) findViewById(R.id.rl_root);


        startAnim();
    }
//开启动画
    private void startAnim() {
        AnimationSet set=new AnimationSet(false);//允许进行多个动画设置
        
        //旋转动画
        RotateAnimation rotate=new RotateAnimation(0, 360,
                Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotate.setDuration(1500);//动画时间
        rotate.setFillAfter(true);//保持动画状态
        
        //缩放动画
        ScaleAnimation scale=new ScaleAnimation(0, 1, 0, 1,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);        
        scale.setDuration(1500);//动画时间
        scale.setFillAfter(true);//保持动画状态
        
        //渐变动画
        AlphaAnimation alpha=new AlphaAnimation(0, 1);
        alpha.setDuration(1500);//动画时间
        alpha.setFillAfter(true);//保持动画状态
        
        set.addAnimation(rotate);
        set.addAnimation(scale);
        set.addAnimation(alpha);
        
        //设置动画监听,
        set.setAnimationListener(new AnimationListener() {
            
            @Override
            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub
                
            }
            
            @Override
            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub
                
            }
            
            @Override
            public void onAnimationEnd(Animation animation) {
                Nextpager();//判断闪屏结束后跳转的页面
            }
        });
        Rlroot.startAnimation(set);
    }
    
    //判断闪屏结束后跳转的页面
 public void Nextpager(){
     boolean userguide=SharePrefersUtils.getboolean(SlapshActivity.this, "guide_showed", false);
    
     if(!userguide){
         startActivity(new Intent(SlapshActivity.this,GuideActivity.class));//如果引导页没有执行过则动画结束,开始GuideActivity
      }
     else {
         startActivity(new Intent(SlapshActivity.this,MainActivity.class));//引导页执行过则动画结束,开始MianActivity
     }
     finish();
 }
    
}

2.布局文件

<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:background="@drawable/splash_bg_newyear"
   >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/splash_horse_newyear" />

</RelativeLayout>

原文地址:https://www.cnblogs.com/wangying222/p/5269337.html