Android PopWindow alternatives BasePopup

Disclaimer: This article is xing_star original article, please indicate the source!

This article synchronization from http://javaexception.com/archives/109

Background Description

Recently, they see this open source project BasePopup, remember the first concern of this project is 17 years, submitted records commit looked at, from the beginning of 16 years to maintain 19 years, is still very perseverance to see that issue as well as documents author very carefully, praise for the author points. Do Android development for many years, with regard to the use of seemingly PopWindow is definitely not special, pop before technology is basically use the DialogFragment, a custom BaseDialogFragment, agreed some ways, ultimately expand the subclass to achieve, basically satisfied the vast majority of pop needs, whether it is the bottom of the pop, pop intermediate, full-screen pop or something else, and some can be used AlertDialog the like to achieve, popWindow use very rarely encountered, recently contacted a few projects, but added more use Popwindow place, of course, it stands to reason that these pop-ups can also use Dialog or DialogFragment achieve, but the project has been adopted PopWindow way, try to maintain the unity of technology.

PopWindow usage scenarios

In general, contains conditions used for screening, such as multi-level conditions on the US group screening, or screening conditions on other app, imitation BootomSheet the bottom of the pop-up effect (with Dialog, PopWindow can be achieved), imitation circle of friends Comments like point of PopWindow effect, imitation AlertDialog pop like PopWindow (since this system provides, then use the system, you do not need to achieve this effect in the custom PopWindow), as well as gradual fade animation effect of pop effects, such as QQ space inside that box click bomb, basically with PopWindow can achieve most of the pop-demand (you may run into a lot of the pit, so here is a little help from under BasePopup), PopWindow have a big advantage, that is, display position control may pop fine-grained, such as the current view of the vertical and horizontal orientations, etc., or a point slightly offset, are possible. This is Dialog, or DialogFragment can not be compared.

Use the default issue PopWindow encounter

I believe you had quite a few problems with PopWindow process, here we are a few common problems.

1. Set the main layout root node is invalid size (layout_width, layout_height), in which case we need to add a layer of the root parent container, so that the parent container becomes the root xml

2.Android N popWindow above apparatus shows a problem, and the presence of shadows coverage problems, this reading this description http://javaexception.com/archives/108

3. Using measurement window, control the size, width and height were measured 0

4. minutiae and many more, not one by one example

demo of the effect BasePopup

Followed by the bottom of the pop, popWindow supports input text input, fake friends punctuate Like Comment effect

Experience demo apk address https://fir.im/pfc9

Use project

想要使用BasePopup直接到对应的github上按照对应的文档接入,教程写的很详细,有问题也可以在issue里面查找,再贴一下项目地址https://github.com/razerdp/BasePopup

参考资料

popupWindow使用常见的错误 https://www.jianshu.com/p/d352847cc08b

BasePopup项目地址 https://github.com/razerdp/BasePopup

Guess you like

Origin www.cnblogs.com/xing-star/p/10961988.html