Android flash screen effect implementation method

  • 2021-01-22 05:21:32
  • OfStack

This paper describes the Android flash screen effect implementation method. To share with you for your reference, as follows:

Flash screen, SplashScreen, also can be said to be the startup screen, is the startup, flash (display)1 time, lasts a few seconds, and then automatically close.

The implementation of android is very simple and can be implemented using postDelayed methods on Handler objects. Pass an Runnable object and a delay time in this method. This method implements the effect of one delay, specified by the second argument, in milliseconds. The first argument is the Runnable object, which contains the actions that need to be performed after the delay. The demo code is as follows:

Java code:


package com.mstar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class ActSplashScreen extends Activity{
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.shan);
 //  Flash screen core code 
 new Handler().postDelayed(new Runnable() {
  @Override
  public void run() {
  Intent intent = new Intent(ActSplashScreen.this,DialogTest.class);
  // From startup animation ui Jump to the main ui
  startActivity(intent);
  ActSplashScreen.this.finish(); //  End the start animation interface 
  }
 }, 3000); // Start Animation Continuation 3 seconds 
 }
}

xml code:


<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >
  <TextView
   android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:text=" flash 1 Under the "
  >
  </TextView>
</LinearLayout>

For more information on Android development, readers who are interested in Android development can check out the following features: Android Animation Tips, Android Multimedia Tips (Audio, Video, Recorder, etc.) and Android Introduction and Advanced Tutorials

I hope this article described to everyone Android program design is helpful.


Related articles: