博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android 渐变展示启动屏
阅读量:7126 次
发布时间:2019-06-28

本文共 1849 字,大约阅读时间需要 6 分钟。

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

         Android 应用程序创建一个启动界面Splash Screen非常简单。

布局文件:splash.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns: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>

运行效果:

转载地址:http://xtxel.baihongyu.com/

你可能感兴趣的文章
你的无人机快递来了?小心被查“水表”
查看>>
收录 Uboot 详解
查看>>
MongoDB数据库的索引操作(转)
查看>>
线程的实现
查看>>
重建日志文件
查看>>
鱼鹰软件荣获“北京广告产业发展30周年”杰出贡献单位奖
查看>>
四、oracle基本sql语句和函数详解
查看>>
中合国创杯2017年创客中国互联网+创新创业大赛复赛成功举办 20各项目入围总决赛...
查看>>
UVAoj 11324 - The Largest Clique(tarjan + dp)
查看>>
使用Matplotlib绘制正余弦函数、抛物线
查看>>
四位辉光管时钟-学长毕设
查看>>
大话RAC介质恢复---联机日志损坏
查看>>
oracle 内存分配和调优 总结
查看>>
移植最新版libmemcached到VC++的艰苦历程和经验总结(上)
查看>>
诡异的bug: tcsh陷入死循环
查看>>
java-第一章-上机练习-04
查看>>
Active Directory 基础 (1)
查看>>
xml地图生成网址
查看>>
Python 练习1
查看>>
TCExam文件代码注释分析(后台首页admin/code/index.php)
查看>>