本程序在别人的代码的基础上更改而成。

下载地址:http://download.csdn.net/detail/hong0220/4670232

核心代码:

SplashScreen.java

[java] view plain copy
  1. packagecom.yourname.main;
  2. importandroid.app.Activity;
  3. importandroid.content.Intent;
  4. importandroid.graphics.drawable.AnimationDrawable;
  5. importandroid.os.Bundle;
  6. importandroid.view.Menu;
  7. importandroid.view.MotionEvent;
  8. importandroid.widget.ImageView;
  9. publicclassSplashScreenextendsActivity{
  10. privateThreadmSplashThread;
  11. @Override
  12. publicvoidonCreate(BundlesavedInstanceState){
  13. super.onCreate(savedInstanceState);
  14. setContentView(R.layout.splash);
  15. finalImageViewsplashImageView=(ImageView)findViewById(R.id.SplashImageView);
  16. splashImageView.setBackgroundResource(R.drawable.flag);
  17. finalAnimationDrawableframeAnimation=(AnimationDrawable)splashImageView.getBackground();
  18. splashImageView.post(newRunnable(){
  19. @Override
  20. publicvoidrun(){
  21. frameAnimation.start();
  22. }
  23. });
  24. mSplashThread=newThread(){
  25. @Override
  26. publicvoidrun(){
  27. try{
  28. synchronized(this){
  29. wait(10000);
  30. }
  31. }
  32. catch(InterruptedExceptionex){
  33. }
  34. finish();
  35. }
  36. };
  37. mSplashThread.start();
  38. }
  39. @Override
  40. publicbooleanonTouchEvent(MotionEventevt)
  41. {
  42. if(evt.getAction()==MotionEvent.ACTION_DOWN)
  43. {
  44. synchronized(mSplashThread){
  45. finish();
  46. }
  47. }
  48. returntrue;
  49. }
  50. }


BootBroadcastReceiver.java

[java] view plain copy
  1. packagecom.yourname.main;
  2. importandroid.content.BroadcastReceiver;
  3. importandroid.content.Context;
  4. importandroid.content.Intent;
  5. publicclassBootBroadcastReceiverextendsBroadcastReceiver{
  6. staticfinalStringACTION="android.intent.action.BOOT_COMPLETED";
  7. @Override
  8. publicvoidonReceive(Contextcontext,Intentintent){
  9. if(intent.getAction().equals(ACTION)){
  10. IntentsayHelloIntent=newIntent(context,SplashScreen.class);
  11. sayHelloIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12. context.startActivity(sayHelloIntent);
  13. }
  14. }
  15. }


配置文件

AndroidManifest.xml

[plain] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <manifestxmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.yourname.main"
  4. android:versionCode="1"
  5. android:versionName="1.0">
  6. <applicationandroid:icon="@drawable/icon"android:label="@string/app_name">
  7. <activity
  8. android:name="SplashScreen"
  9. android:theme="@style/Theme.Transparent">
  10. <intent-filter>
  11. <actionandroid:name="android.intent.action.MAIN"></action>
  12. <categoryandroid:name="android.intent.category.LAUNCHER"></category>
  13. </intent-filter>
  14. </activity>
  15. <receiverandroid:name=".BootBroadcastReceiver">
  16. <intent-filter>
  17. <actionandroid:name="android.intent.action.BOOT_COMPLETED"/>
  18. <categoryandroid:name="android.intent.category.LAUNCHER"/>
  19. </intent-filter>
  20. </receiver>
  21. </application>
  22. <uses-sdkandroid:minSdkVersion="7"/>
  23. </manifest>


layout/splash.xml

[plain] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:layout_width="wrap_content"
  5. android:layout_height="wrap_content"
  6. android:id="@+id/TheSplashLayout"
  7. android:layout_gravity="center"
  8. >
  9. <ImageView
  10. android:layout_width="wrap_content"
  11. android:layout_height="wrap_content"
  12. android:id="@+id/SplashImageView"
  13. android:layout_gravity="center"
  14. >
  15. </ImageView>
  16. </LinearLayout>


values/styles.xml

[plain] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <resources>
  3. <style
  4. name="SplashScreen">
  5. parent="@android:Animation"
  6. <itemname="android:windowEnterAnimation">@drawable/appear</item>
  7. <itemname="android:windowExitAnimation">@drawable/disappear</item>
  8. </style>
  9. <style
  10. name="Theme.Transparent"
  11. parent="android:Theme">
  12. <itemname="android:windowIsTranslucent">true</item>
  13. <itemname="android:windowBackground">@android:color/transparent</item>
  14. <itemname="android:windowNoTitle">true</item>
  15. <itemname="android:windowAnimationStyle">@style/SplashScreen</item>
  16. </style>
  17. </resources>


drawable/flag.xml

[plain] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <animation-list
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:id="@+id/flaganim"
  5. android:oneshot="false"
  6. >
  7. <itemandroid:drawable="@drawable/f03"android:duration="1000"/>
  8. <itemandroid:drawable="@drawable/f04"android:duration="1000"/>
  9. <itemandroid:drawable="@drawable/f05"android:duration="1000"/>
  10. <itemandroid:drawable="@drawable/f06"android:duration="1000"/>
  11. <itemandroid:drawable="@drawable/f07"android:duration="1000"/>
  12. <itemandroid:drawable="@drawable/f08"android:duration="1000"/>
  13. <itemandroid:drawable="@drawable/f09"android:duration="1000"/>
  14. <itemandroid:drawable="@drawable/f10"android:duration="1000"/>
  15. </animation-list>

drawable/appear.xml

[plain] view plain copy
  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <setxmlns:android="http://schemas.android.com/apk/res/android">
  3. <alpha
  4. android:interpolator="@android:anim/accelerate_interpolator"
  5. android:fromAlpha="0.0"android:toAlpha="1.0"
  6. android:duration="800"
  7. />
  8. </set>

Drawable/disappear.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android"><alphaandroid:interpolator="@android:anim/decelerate_interpolator"android:fromAlpha="1.0" android:toAlpha="0.0"android:duration="800"/></set>


更多相关文章

  1. android 读取 attr 资源
  2. Android(安卓)studio简易计算机
  3. Android中几种图片特效的处理的实现方法
  4. Android(安卓)去掉title bar的3个方法
  5. 从网上找的Android实用代码,记录备用
  6. 如何判断Android/IOS是否安装应用。
  7. Android(安卓)常用代码片小结
  8. (Android) ContentProvider 实例
  9. Android中用Handle做定时器,显示实时时间

随机推荐

  1. Android(安卓)BaseExpandableListAdapter
  2. Android:横行滚动且隔行变色的ListView控
  3. Android屏幕点亮(常亮)及屏幕解锁和锁定
  4. Android(安卓)关于wifi管理的代码
  5. Android(安卓)proguard(混淆)模板
  6. Android快速开发之封装标题栏
  7. android 实现自定义隐藏式菜单
  8. android 开发环境搭建
  9. 构建更好的应用--Xamarin平台
  10. android recovery升级原理及update.zip升