zoukankan      html  css  js  c++  java
  • 闪屏效果

    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>

  • 相关阅读:
    iOS 设计模式-委托模式
    python中时间操作总结
    list、dict、tuple的一些小操作总结
    DataFrame的构建及一些操作
    python连接mysql、oracle小例子
    sqlalchemy 映射的小例子
    crontab定时任务以及其中中文乱码问题
    vs2008试用版的评估期已经结束解决办法
    MongoDB 常用shell命令汇总
    把py文件打成exe
  • 原文地址:https://www.cnblogs.com/wangying222/p/5269337.html
Copyright © 2011-2022 走看看