Android之七 闪屏的实现
16lz
2021-01-23
Android之七 闪屏的实现
可以有两种方法实现:一:在主文件中写入<span style="font-size:14px;"> // 取消标题 this.requestWindowFeature(Window.FEATURE_NO_TITLE); // 取消状态栏 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); </span>
二:可以在AndroidManifest.xml配置文件中修改显示的状态在application应用程序中加入
<span style="font-size:14px;"> <activity android:name="com.example.walkerlogin1.WelcomeActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > </activity></span>
下面是具体 的实现代码:
package com.example.walkerlogin1;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.Animation.AnimationListener;import android.widget.RelativeLayout;public class WelcomeActivity extends Activity {protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 取消标题 this.requestWindowFeature(Window.FEATURE_NO_TITLE); // 取消状态栏 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_welcome); RelativeLayout layoutWelcome=(RelativeLayout) findViewById(R.id.activity_welcome); AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f); alphaAnimation.setDuration(3000); layoutWelcome.startAnimation(alphaAnimation); alphaAnimation.setAnimationListener(new AnimationListener() { public void onAnimationStart(Animation animation) { } public void onAnimationRepeat(Animation animation) { } public void onAnimationEnd(Animation animation) { System.out.println("你好");Intent intent=new Intent(WelcomeActivity.this,GuideActivity.class); startActivity(intent); } }); }}也可以在配置文件中修改
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.walkerlogin1" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.walkerlogin1.MainActivity" android:label="@string/app_name"></activity> <activity android:name="com.example.walkerlogin1.WelcomeActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="android.intent.action.MAIN" />//取消标题栏 <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>UI布局代码:activity_welcome.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/welcome_bg" tools:context=".WelcomeActivity" android:id="@+id/activity_welcome"></RelativeLayout>最终显示界面:
更多相关文章
- Android移动操作系统源代码
- Android Studio系列(二)使用Android Studio开发/调试整个android系
- Android开发常用代码片段(三)
- Android 性能优化之Java(Android)代码优化 (三)
- Android常用代码之普通及系统权限静默安装APK
- android中删除启动界面的时候弹出的显示标题栏
- 设置无标题&设置不显示状态栏
- android 常用代码
- 常用的android权限配置和常用工具代码