Android uses handler and countdowntimer to realize the flashing page with countdown

The last blog post "Analysis on the use of handler in Android" introduced the use method and implementation principle of handler by making the countdown flash screen page. The bug in the implementation process was also mentioned at the end of the blog. Interested friends can click the link to go back and have a look. Today, the full version of countdown flash screen is realized by using handler and countdowntimer (it will not jump to the page after exiting the flash page).

1. The results are as follows:

1.1 effect of normal entry jump and log display

1.2 exit and log display when the countdown is not over

Compared with the implementation of the previous blog post, the timing stops after exiting and will not jump to the new interface

2. Implementation method

2.1 remove actionbar

The flash screen page is generally displayed in full screen. Here, we first need to remove the actionbar and set it in RES / values / styles.xml:

It is also suggested that you should try not to use rigid actionbar in later development. You can use toolbar or custom titlebar components to replace actionbar according to project requirements. In this way, the interface design will be more flexible.

2.2 layout

Here, only the layout background picture is set, and textview is added in the upper right corner to display the countdown. Sorry, the code is as follows:

2.3 Java implementation code

In 2.1, only the action bar of the app is removed. To do full screen display, you still need to use code settings in the activity.

The above is the flash screen page including countdown in Android using handler and countdowntimer introduced by Xiaobian. I hope it will be helpful to you!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>