zoukankan      html  css  js  c++  java
  • android 渐变展示启动屏

       启动界面Splash Screen在应用程序是很常用的,往往在启动界面中显示产品Logo、公司Logo或者开发者信息,如果应用程序启动时间比较长,那么启动界面就是一个很好的东西,可以让用户耐心等待这段枯燥的时间。
             Android 应用程序创建一个启动界面Splash Screen非常简单。

    布局文件:splash.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/splash" --资源图片splash.jpg
        android:gravity="bottom"
        android:orientation="vertical" >

    </LinearLayout>

    Activity文件:(SplashActivity.java)

    package lcl.android.activity;

    import lcl.android.R;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.view.View;
    import android.view.animation.AlphaAnimation;
    import android.view.animation.Animation;
    import android.view.animation.Animation.AnimationListener;

    public class SplashActivity extends FragmentActivity {
        @Override
        protected void onCreate(Bundle arg0) {
            super.onCreate(arg0);
            final View view = View.inflate(this, R.layout.splash, null);
            setContentView(view);

            // 渐变展示启动屏
            AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
            aa.setDuration(2000);
            view.startAnimation(aa);
            aa.setAnimationListener(new AnimationListener() {
                @Override
                public void onAnimationEnd(Animation arg0) {
                    redirectTo();
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationStart(Animation animation) {
                }

            });
        }

        /**
         * 跳转到...
         */
        private void redirectTo() {
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    }


    AndroidManifest.xml

    <activity
        android:name="lcl.android.activity.SplashActivity"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    运行效果:

    image

  • 相关阅读:
    实验一
    MVVM Light Toolkit 学习
    配置mongodb分片群集(sharding cluster)
    【silverlight】web发布方法
    MongoDb数据库设计
    【解决方案】添加web服务失败:下载“http://localhost:2540/Service.asmx”时出错。无法生成***类型
    Codeforces #380 div2 C(729C) Road to Cinema
    Codeforces #380 div2 B(729B) Spotlights
    数据挖掘项目总结
    南方电网用电时间序列分析
  • 原文地址:https://www.cnblogs.com/luomingui/p/3859495.html
Copyright © 2011-2022 走看看