The words written by the pop-up window. Although very simple. But not silky enough. If you want to be more elegant. Add animation again. but. . . If XPopup is used, someone else will write the animation for you. Are you happy? Silky not silky. . ?
Silky first step. Introduce dependencies first
implementation 'com.github.li-xiaojun:XPopup:2.9.19'
Without these dependent libraries. also add
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
xpopup depends on subsampling-scale-image-view, if you also depend on this library and the version conflicts, you can do an exclude :
implementation ('com.github.li-xiaojun:XPopup:版本号看上面'){
exclude group: "com.davemorrissey.labs", module: "subsampling-scale-image-view-androidx"
}
Then you can use it. example. . . Let's have some bubbles first. Like this,
you need to define an xml layout file yourself. The document does not go into too much detail. . Realize it yourself according to the business.
Then use a Dialog to refer to this layout file. . Remember. . Dialog depends on BubbleAttachPopupView. As follows:
Finally. Just call:
XPopup.Builder(this)
.isDestroyOnDismiss(true)
.atView(binding!!.ivMenu)
.hasShadowBg(false) // 去掉半透明背景
.offsetY(SizeUtils.dp2px(1f))
.asCustom(
EmailInboxDialog(this)
.setBubbleBgColor(x)//设置弹窗颜色
.setArrowWidth(SizeUtils.dp2px(5f))
.setArrowHeight(SizeUtils.dp2px(6f))
.setBubbleRadius(SizeUtils.dp2px(15f))
.setArrowRadius(SizeUtils.dp2px(3f))
).show()
leftover. There are many more popups that can be used. No more details.
You can browse the API yourself: github address
end