zoukankan      html  css  js  c++  java
  • android欢迎界面淡入淡出效果

    很多Android应用一开始都会有一个欢迎界面,淡入淡出效果也是用得非常多的,下面来实现一下。

    主要代码如下:

    package com.myaibang.activity;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.CountDownTimer;
    import android.view.Window;
    import android.view.WindowManager;

    public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    new CountDownTimer(2000,1000) {

    @Override
    public void onTick(long millisUntilFinished) {
    }
    @Override
    public void onFinish() {
    Intent intent = new Intent();
    intent.setClass(MainActivity.this, SecondActivity.class);
    startActivity(intent);

    int VERSION=Integer.parseInt(android.os.Build.VERSION.SDK);
    if(VERSION >= 5){
    MainActivity.this.overridePendingTransition(R.anim.alpha_in, R.anim.alpha_out);
    }
    finish();
    }
    }.start();
    }
    }

    还需要两个xml文件,主要是对应淡入和淡出效果:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <set
    xmlns:android=”http://schemas.android.com/apk/res/android”>
    <alpha
    android:fromAlpha=”0.0″
    android:toAlpha=”1.0″
    android:duration=”2000″ />
    </set>

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <set
    xmlns:android=”http://schemas.android.com/apk/res/android”>
    <alpha
    android:fromAlpha=”1.0″
    android:toAlpha=”0.0″
    android:duration=”2000″ />
    </set>

    这就实现了淡入淡出效果,还不错哦!试试吧!

  • 相关阅读:
    Android Studio 优秀插件: Parcelable Code Generator
    Android Studio 优秀插件:GsonFormat
    DrawerLayout(抽屉效果)
    Python拼接字符串的七种方式
    Python爬虫教程-使用chardet
    Python爬虫教程-实现百度翻译
    Tensorflow分布式部署和开发
    简单的Python GUI界面框架
    用keras构建自己的网络层 TensorFlow2.0教程
    Python GUI教程一:Hello World
  • 原文地址:https://www.cnblogs.com/hxxy2003/p/2603062.html
Copyright © 2011-2022 走看看