android系统开机画面_Android开机画面

android系统开机画面_Android开机画面制作android开机画面AndroidSplashScreenisthefirstscreenvisibletotheuserwhentheapplication’slaunched.Splashscreenisoneofthemostvitalscreensintheapplicationsinceit’stheuser’sfirs…

大家好,又见面了,我是你们的朋友全栈君。

android系统开机画面

Android Splash Screen is the first screen visible to the user when the application’s launched. Splash screen is one of the most vital screens in the application since it’s the user’s first experience with the application.

Android启动画面是启动应用程序时用户可见的第一个屏幕。 闪屏是应用程序中最重要的屏幕之一,因为它是用户对应用程序的首次体验。

Splash screens are used to display some animations (typically of the application logo) and illustrations while some data for the next screens are fetched.

启动屏幕用于显示某些动画(通常是应用程序徽标)和插图,同时获取下一个屏幕的一些数据。

Android开机画面 (Android Splash Screen)

Typically, the Activity that has the following intent filter set in the AndroidManifest.xml file is the Splash Activity.

通常,在AndroidManifest.xml文件中设置了以下意图过滤器的Activity是Splash Activity。

<intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

Android启动画面示例项目结构 (Android Splash Screen Example Project Structure)

There are few ways to create the initial screen i.e. Splash Screen of the application. Let’s see each of them.

有几种创建初始屏幕的方法,即应用程序的启动屏幕。 让我们看看它们中的每一个。

闪屏经典方法 (Splash Screen Classical Approach)

SplashActivity.java

package com.journaldev.splashscreen;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable() {


            @Override
            public void run() {
                // This method will be executed once the timer is over
                Intent i = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(i);
                finish();
            }
        }, 5000);
    }
}

This is how we normally create the layout of our Splash Screen in our application:
activity_splash.xml

通常,这就是我们在应用程序中创建启动画面布局的方式:
activity_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="https://schemas.android.com/apk/res/android"
    xmlns:app="https://schemas.android.com/apk/res-auto"
    xmlns:tools="https://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    tools:context="com.journaldev.splashscreen.SplashActivity">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="72dp"
        android:layout_height="72dp"
        android:src="@mipmap/ic_launcher"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@id/imageView" />

</android.support.constraint.ConstraintLayout>

Let’s keep the MainActivity.java empty for now.

让我们MainActivity.java保持MainActivity.java空。

The output produced from the above implementation of SplashScreen is given below. We’ve set the theme of the SplashActivity to Theme.AppCompat.NoActionBar in the AndroidManifest.xml file.

下面是上述SplashScreen的实现所产生的输出。 我们设置了SplashActivity到Theme.AppCompat.NoActionBar在主题AndroidManifest.xml文件。

Did you see the blank page that came up before the Splash Screen was visible to you?

在启动画面可见之前,您是否看到空白页面?

The above approach isn’t the correct approach. It’ll give rise to cold starts.

上面的方法不是正确的方法。 它会引起冷启动

The purpose of a Splash Screen is to quickly display a beautiful screen while the application fetches the relevant content if any (from network calls/database).
With the above approach, there’s an additional overhead that the SplashActivity uses to create its layout.

启动屏幕的目的是在应用程序获取相关内容(从网络调用/数据库)中获取相关内容时,快速显示漂亮的屏幕。
使用上述方法, SplashActivity使用额外的开销来创建其布局。

It’ll give rise to slow starts to the application which is bad for the user experience (wherein a blank black/white screen appears).

它将导致应用程序启动缓慢,这不利于用户体验(其中出现黑屏/白屏)。

带有正确方法的Android启动画面示例 (Android Splash Screen Example with Correct Approach)

The cold start appears since the application takes time to load the layout file of the Splash Activity. So instead of creating the layout, we’ll use the power of the application theme to create our initial layout.

由于应用程序需要时间来加载Splash Activity的布局文件,因此出现冷启动。 因此,我们将使用应用程序主题的功能来创建初始布局,而不是创建布局。

Application theme is instantiated before the layout is created. We’ll set a drawable inside the android:windowBackground attribute that’ll comprise of the Activity’s background and an icon using layer-list as shown below.

在创建布局之前,将实例化应用程序主题。 我们将在android:windowBackground属性内设置一个drawable,该属性android:windowBackground Activity的背景和使用layer-list的图标组成,如下所示。

splash_background.xml

splash_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="https://schemas.android.com/apk/res/android">

    <item android:drawable="@android:color/black" />
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher" />
    </item>
</layer-list>

We’ll set the following style as the theme of the activity.

我们将以下样式设置为活动的主题。

styles.xml

styles.xml

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_background</item>
    </style>

The SplashActivity.java file should look like this:

SplashActivity.java文件应如下所示:

package com.journaldev.splashscreen;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        new Handler().postDelayed(new Runnable() {


            @Override
            public void run() {
                // This method will be executed once the timer is over
                Intent i = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(i);
                finish();
            }
        }, 5000);
    }
}

Note: the theme of the activity is set before anything else. Hence the above approach would give our app a quicker start.

注意:活动的主题设置在其他任何主题之前。 因此,以上方法将使我们的应用程序更快速地启动。

Using the theme and removing the layout from the SplashActivity is the correct way to create a splash screen.
This brings an end to android splash screen tutorial. You can download the final Android Splash Screen Project from the link below.

使用主题并从SplashActivity中删除布局是创建初始屏幕的正确方法。
这结束了android启动画面教程。 您可以从下面的链接下载最终的Android Splash Screen Project。

翻译自: https://www.journaldev.com/17831/android-splash-screen

android系统开机画面

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/146555.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • CLion linux激活码【中文破解版】

    (CLion linux激活码)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.htmlS32PGH0SQB-eyJsaWNlbnNlSWQi…

    2022年3月26日
    33
  • java队列(Queue)用法总结[通俗易懂]

    java队列(Queue)用法总结[通俗易懂]1.队列的特点队列是一种比较特殊的线性结构。它只允许在表的前端(front)进行删除操作,而在表的后端(rear)进行插入操作。进行插入操作的端称为队尾,进行删除操作的端称为队头。队列中最先插入的元素也将最先被删除,对应的最后插入的元素将最后被删除。因此队列又称为“先进先出”(FIFO—firstinfirstout)的线性表,与栈(FILO-firstinlastout)刚好相反…

    2022年7月14日
    16
  • 160亿数据点图表控件LightningChart振动分析可以检测什么?

    160亿数据点图表控件LightningChart振动分析可以检测什么?LightningChart.NET完全由GPU加速,并且性能经过优化,可用于实时显示海量数据-超过10亿个数据点。LightningChart包括广泛的2D,高级3D,Polar,Smith,3D饼/甜甜圈,地理地图和GIS图表以及适用于科学,工程,医学,航空,贸易,能源和其他领域的体绘制功能。点击下载LightningChart.NET最新试用版当您想到振动分析时,您会想到什么?它正在成为结构工程中一种非常常见的识别方法,用于识别潜在的结构完整性问题,例如隐藏的物体或空隙。这是一种识别机械问题的

    2022年10月15日
    0
  • OSS对象储存_oss存储是什么意思

    OSS对象储存_oss存储是什么意思简介阿里云对象存储服务(ObjectStorageService,简称OSS),是阿里云提供的海量、安全、低成本、高可靠的云存储服务。使用流程名词解释Endpoint(访问域名)Acc

    2022年8月1日
    3
  • 十进制小数转换为二进制小数采用方法为乘2取整法?_小数点二进制转10进制

    十进制小数转换为二进制小数采用方法为乘2取整法?_小数点二进制转10进制十进制小数转换成二进制小数采用"乘2取整,顺序排列"法。具体做法是:用2乘十进制小数,可以得到积,将积的整数部分取出,再用2乘余下的小数部分,又得到一个积,再将积的整数部分取出,如此进行,直到积中的整数部分为零,或者整数部分为1,此时0或1为二进制的最后一位。或者达到所要求的精度为止。  然后把取出的整数部分按顺序排列起来,先取的整数作为二进制小数的高位有效位,后取的整数作为低位有…

    2022年9月24日
    0
  • Java:Eclipse下载安装教程,以及Eclipse 安装汉化包的方法[通俗易懂]

    Java:Eclipse下载安装教程,以及Eclipse 安装汉化包的方法[通俗易懂]Eclipse是目前最流行的Java语言开发工具,它强大的代码辅助功能,可以帮助开发人员自动完成语法修正、补全文字、代码修复、API提示等编码工作,大量节省程序开发所需的时间。本教程使用Eclipse为开发工具,下面介绍它的安装。(1)Eclipse是一个开放源代码的项目,其官方网站是www.eclipse.org。图1所示为Eclipse官方网站的首页。图…

    2022年5月20日
    40

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号