Solution of pop-up login box for Android

Here is my implementation experience:

1. First of all, I directly used alertdialog to implement it. I'm sure that the shape is a little ugly, and it's a little troublesome to obtain the controls in the dialog (because the login box I want to make has a certain layout), and then gave it up to me. Maybe I'm too water to use it well

2. Then I use popupwindow to implement it. The interface meets my requirements. It is relatively simple to obtain the control through the inflator. However, one disadvantage is that when you click input, the dialog box will not change its position according to the position of the soft keyboard. After searching on the Internet, you can't directly monitor the event messages of the emergence and disappearance of the soft keyboard, Struggled all afternoon and gave up decisively.

3. Finally, the activity is used directly. The interface meets the requirements, the control is easy to obtain, and the position can be changed according to the soft keyboard. The collective implementation is as follows:

First, create an activity and arrange the corresponding layout.

Second, I think it is the most important part. When registering an activity, set the theme attribute of the activity to dialog, and customize your own style file so that the display of the activity can be implemented according to your own requirements. The specific code is as follows:

Where login_ The dialog file is as follows:

3. Finally, if you want to call other activities, just call them like that

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