Efficient start page (Splash) to start splash

Source: Internet
Author: User

Efficient start page (Splash) to start splash

When many applications start, a page is required to display the company's brand or Logo, or even if this page is not needed, if the layout is complex, when starting an application, there will be a short white screen (related to the system topic). We often write an Activity separately and then display an image or Logo, set a fixed time delay to start the real MainActivity. In this way, you can share a small skill:


  • First, use layer-list to define a hierarchical drawable:

1234567891011 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">    <item>        <color android:color="@color/background_material_light"/>    </item>    <item>        <bitmap            android:src="@drawable/launch_logo_image"            android:tileMode="disabled"            android:gravity="center"/>    </item></layer-list>

Define the background color and a bitmap Logo. the Logo is displayed in the center. Areas beyond the bitmap size are not tiled or processed;

  • Then apply it to the global background (when the application starts, the topic is rendered first. If the system topic is not set by default ):

12345 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar" />  <style name="AppTheme.BrandedLaunch" parent="AppTheme">    <item name="android:windowBackground">@drawable/branded_logo</item></style>
  • Portal Activity setting topic:

1234 <activity    android:name=".MainActivity"    android:label="@string/app_name"    android:theme="@style/AppTheme.BrandedLaunch">

As this will change the overall theme, you can change it dynamically in onCreate to return to the original default theme:

123456 @Overrideprotected void onCreate(Bundle savedInstanceState) {    setTheme(R.style.AppTheme);    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);}


A short white screen is displayed before the application is started:


After using this method:


Is it much more comfortable.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.