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>

  • 相关阅读:
    php 替换二维数组的 key
    全选功能
    向数组中添加含有下标的元素
    判断一个进程是否在执行中
    初识 Nginx
    原生JS中DOM节点相关API合集
    工作中经常用到github上优秀、实用、轻量级、无依赖的插件和库
    Unsupported major.minor version ... JDK具体对应版本
    Scala常用命令
    使用nexus搭建maven私服教程详解
  • 原文地址:https://www.cnblogs.com/wangying222/p/5269337.html
Copyright © 2011-2022 走看看