Android启动页面(闪屏页面)的实现
来源:互联网 发布:直销返利系统源码 编辑:程序博客网 时间:2024/06/02 12:03
闪屏页面是指APP刚启动时的页面会自动跳转到主页面
单单实现闪屏页面非常简单。
闪屏界面的作用:
1.展示自己软件的logo,口号标识语等,
2.作为广告平台,获取利益
3.加载下一页面(其他Activity或全局)所需要的数据
4.检查更新
效果展示
首先目录结构
SplashActivity
package com.hxh.splashactivitydemo;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.Window;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.widget.RelativeLayout;public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 设置没有标题栏 this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_splash); RelativeLayout layoutSplash=(RelativeLayout) findViewById(R.id.activity_splash); AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f); alphaAnimation.setDuration(1000);//设置动画播放时长1000毫秒(1秒) layoutSplash.startAnimation(alphaAnimation); //设置动画监听 alphaAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } //动画结束 @Override public void onAnimationEnd(Animation animation) { //页面的跳转 Intent intent=new Intent(SplashActivity.this,MainActivity.class); startActivity(intent); } @Override public void onAnimationRepeat(Animation animation) { } }); }}
MainActivity主界面
package com.hxh.splashactivitydemo;import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v7.app.AppCompatActivity;import android.view.Window;/** * Created by HuXiaoHui on 2017/10/9. */public class MainActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); //去掉标题栏 this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); }}
activity_splash.xml文件
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_splash" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash_background" tools:context="com.hxh.splashactivitydemo.SplashActivity"> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="150dp" android:text="SplashDemo" android:textSize="50dp" android:textColor="#fff" /></RelativeLayout>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="100dp" android:text="欢迎进入主界面" android:textSize="30dp" android:textColor="#f00" /></RelativeLayout>
最后还需要更改AndroidManifest.xml
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".SplashActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MainActivity" > </activity> </application>
首先在AndroidManifest.xml中注册新加入的SplashActivity。
然后将的内容放在SplashActivity下。
意思就是让SplashActivity的内容先启动。然后再跳转到MainActivity
需要下载源码的可以点击这里链接
阅读全文
0 0
- Android启动页面(闪屏页面)的实现
- Android程序的启动页面(闪屏页面)设计
- Android 启动页面与广告页面的实现
- Android 启动引导页面的实现
- Android 实现启动页面冷启动
- iOS及Android 启动页面(即欢迎页面),引导页面,及广告页面的加载
- android 启动页面的设置
- android锁屏页面的实现
- 安卓启动页面的实现
- android应用启动页面
- Android启动页面整理
- android 启动页面
- Android APP启动页面
- Android启动页面制作
- Android应用启动页面
- android 启动页面
- android 启动页面
- android启动页面
- 数据结构系统回顾与总结(3)(判断是否为同一棵二叉搜索树)
- vuejs 使用MintUI Loadmore下拉/上拉刷新,刷新框架
- java: java中的 getInstance() 的理解
- Jmeter断言之响应断言-响应断言名词详细解释
- 被人遗忘的MAX_FILE_SIZE文件上传限制大小参数
- Android启动页面(闪屏页面)的实现
- 未来AI晶片发展有八大新趋势
- python 装饰器理解
- Gradle各版本下载地址
- 编写更好Python程序的5个技巧
- spoj LCS2(多个串的最长公共子序列,后缀自动机)
- Android获取IP地址
- 手机端页面自适应解决方案—rem布局
- Linux系统基础(四)