Android implementation of the pop up login box scheme

  • 2020-06-03 08:19:52
  • OfStack

Here is my implementation experience:

1. First of all, I used AlertDialog to implement it directly. Sure, the shape is a little ugly, and it is a little troublesome to get the control inside Dialog (because the login box I want to make has a definite layout)

2. Then I use PopupWindow, interface is meet my requirements, the control of the approved Inflater can get relatively simple, but there is one drawback is that when click on the input dialog box will not change the position according to the location of the soft keyboard, the search on the net search, also cannot directly to monitor the appearance and disappearance of soft keyboard event messages, struggled for one afternoon, determined to give up.

3. Finally, Activity is directly used to achieve, 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 Activity and lay out the layout accordingly.

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


<activity
      android:name="com.zsxy.schedule.Login"
      android:theme="@style/login_dialog" >
    </activity>

The login_dialog file is as follows:


<style name="login_dialog" parent="@android:style/Theme.Dialog">
 <item name="android:colorBackgroundCacheHint">@null</item>
 <item name="android:windowFrame">@null</item>
 <item name="android:windowIsFloating">true</item>
 <item name="android:windowIsTranslucent">true</item>
 <item name="android:windowNoTitle">true</item>
 <item name="android:windowBackground">@android:color/transparent</item>
 <item name="android:backgroundDimEnabled">false</item>
  </style>

3. Finally, just call as you would any other Activity


Related articles: