Android high imitation wechat payment digital keyboard function

Now many app payment and password entry functions have begun to use the custom numeric keypad, which is not only more convenient, but also has a really exquisite effect.

Let's take you to learn how to highly imitate the wechat digital keyboard, which can be directly used in your own projects.

First look at the renderings:

1. Custom layout

The layout of the keyboard is essentially a GridView with 4x3 grid layout.

2. Realize the content of digital keyboard

Let's see how the adapter handles it: keyboardadapter. Java

Before looking at the adapter, let's look at the grid_ item_ virtual_ How is the keyboard implemented

You can see that in the item layout file, we specify two views, one is the textview that displays numbers normally, and the other is the relativelayout that displays the last delete key. Then, in the getview method of keyboardadapter, we handle the layout differently according to the position position. When position is 9, that is, the penultimate key, its button color should be set separately. When position is 12, that is, the last button, you need to control the display of the delete button and the hiding of the number button. In other cases, the delete button is hidden and the number button is displayed.

3. Use and implement keyboard event logic

In the layout, you can directly use your own defined numeric keypad:

In activity, we operate the numeric keypad:

Source address: https://github.com/zuiwuyuan/WeChatPswKeyboard

The above is the Android high imitation wechat payment digital keyboard function introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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