安卓项目实现闪屏功能

方法1:在主文件中写入

1 <span style="font-size:14px;">  // 取消标题    
2         this.requestWindowFeature(Window.FEATURE_NO_TITLE);    
3         // 取消状态栏    
4         this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,    
5                 WindowManager.LayoutParams.FLAG_FULLSCREEN);  </span>  

方法2:在AndroidManifest.xml配置文件中修改显示的状态

1 <span style="font-size:14px;"> <activity  android:name="com.example.walkerlogin1.WelcomeActivity"  
2             android:label="@string/app_name"  
3             android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"  
4             >  
5          
6          </activity></span>  

 

 

具体实现代码

 

 1 package com.example.walkerlogin1;  
 2   
 3   
 4 import android.app.Activity;  
 5 import android.content.Intent;  
 6 import android.os.Bundle;  
 7 import android.view.animation.AlphaAnimation;  
 8 import android.view.animation.Animation;  
 9 import android.view.animation.Animation.AnimationListener;  
10 import android.widget.RelativeLayout;  
11   
12   
13 public class WelcomeActivity extends Activity {  
14   
15     protected void onCreate(Bundle savedInstanceState) {     
16         super.onCreate(savedInstanceState);    
17              // 取消标题    
18              this.requestWindowFeature(Window.FEATURE_NO_TITLE);    
19         // 取消状态栏    
20            this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,    
21                 WindowManager.LayoutParams.FLAG_FULLSCREEN);    
22         setContentView(R.layout.activity_welcome);    
23         RelativeLayout layoutWelcome=(RelativeLayout) findViewById(R.id.activity_welcome);    
24         AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f);     
25         alphaAnimation.setDuration(3000);     
26         layoutWelcome.startAnimation(alphaAnimation);    
27         alphaAnimation.setAnimationListener(new AnimationListener() {      
28             public void onAnimationStart(Animation animation) {   
29   
30             }        
31   
32             public void onAnimationRepeat(Animation animation) {   
33   
34             }       
35   
36             public void onAnimationEnd(Animation animation) {   
37                 System.out.println("你好");  
38                 Intent  intent=new Intent(WelcomeActivity.this,GuideActivity.class);       
39                 startActivity(intent);    
40             }   
41         });    
42     }  
43 }  



修改配置文件:

 1 <?xml version="1.0" encoding="utf-8"?>  
 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
 3     package="com.example.walkerlogin1"  
 4     android:versionCode="1"  
 5     android:versionName="1.0" >  
 6   
 7     <uses-sdk  
 8         android:minSdkVersion="8"  
 9         android:targetSdkVersion="17" />  
10   
11     <application  
12         android:allowBackup="true"  
13         android:icon="@drawable/ic_launcher"  
14         android:label="@string/app_name"  
15         android:theme="@style/AppTheme" >  
16         
17         <activity  android:name="com.example.walkerlogin1.MainActivity"  
18             android:label="@string/app_name"></activity>  
19          <activity  android:name="com.example.walkerlogin1.WelcomeActivity"  
20             android:label="@string/app_name"  
21             android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"  
22             >  
23              <intent-filter>  
24                 <action android:name="android.intent.action.MAIN" />//取消标题栏  
25   
26                 <category android:name="android.intent.category.LAUNCHER" />  
27             </intent-filter>   
28          
29          </activity>  
30            
31     </application>  
32   
33 </manifest>  

 


UI布局 activity_welcome.xml

1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
2     xmlns:tools="http://schemas.android.com/tools"  
3     android:layout_width="match_parent"  
4     android:layout_height="match_parent"  
5     android:background="@drawable/welcome_bg"  
6     tools:context=".WelcomeActivity"   
7     android:id="@+id/activity_welcome">  
8   
9 </RelativeLayout>  

 




 

转载于:https://www.cnblogs.com/yfw07/p/5600278.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值