Detailed explanation of Android App digital unlocking example

Android App digital lock

Recently, I took the time to do the function of digital unlocking. The mobile phone has digital unlocking, which can also be done by app to avoid the privacy leakage of some applications. The following is the implementation effect picture:

Preface: these two days, the boss gave a task to build a digital lock screen interface imitating IOS. He thought that there should be a lot of such things on the Internet. Then he Baidu first. Who knows that there are few cases, and then he downloaded the "source code" with a skeptical attitude. He looked at what was written in it, and then he borrowed the "source code" The idea has been realized by ourselves, as shown in the figure above.

Idea:

Here we can see it as two parts. One part is the input of the above, and the other part is the key at the bottom. Let's look at the above part first. We can regard it as textview, and then respond to the action of the following keys. In the following part, each button in the figure needs to be drawn by itself. The difficulty is to calculate the coordinates of each button according to the coordinates of the first button (the first coordinate we initialize), and then judge which button is clicked according to the touch screen event of the finger

Next, let's look at the core code:

Input box section:

Key part below

As mentioned above, the difficulty lies in calculating the position of the keys. Here, I modified the calculation method according to the demo I downloaded. If you don't understand the Android screen coordinate system, please see the following article:

reference resources:

Detailed explanation of Android coordinate system

GitHub download address: demo download

Thank you for reading, hope to help you, thank you for your support to this site!

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
分享
二维码
< <上一篇
下一篇>>