Android realizes the bottom payment pop-up effect

Effect of payment pop-up window at the bottom of Android:

Implementation ideas:

1. Achieve the pop-up effect of pop-up window by inheriting the user-defined view of popupwindow;

2. Transfer the entered password from the pop-up window to the main interface through callback;

2. Well, that's enough -- > some points for attention are noted in the code;

Custom view code:

Analysis: it's actually very simple. You can't just load the layout into a custom view by loading the layout. The bottomdialogonclicklistener is a custom callback interface and cannot pass values to the main interface.

Main interface code:

Analysis: it can be seen that the code of the main interface is extremely simple, mainly through customizing a help class to display the pop-up window ― > because the pop-up window is likely to be used in multiple interfaces, I prefer this writing method. In addition, the pop-up object is transmitted through callback, so that the display and cancellation of pop-up can be controlled according to the specific situation of network request.

Help class code:

Analysis: two points ― > 1. Load layout file; 2. Control the display and closing of soft keyboard;

Another important point took a lot of time to find: when the window pops up, the soft keyboard usually covers part of the input box, which is very ugly. The reason why this situation does not occur in the demo is that the special processing - > outsourcing the whole pop-up window layout with a layer of Scrollview, which is convenient for the soft keyboard to pop up. When finding the focus of the input box, the whole layout will be pushed up. However, this is not enough. You must set a property in Scrollview:

android:fillViewport="true"

Finally, GitHub address > > https://github.com/ganshenml/BottomDialogApp

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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