版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cjh_android/article/details/80064850
我发现在 Android 7.0 及以上 showAsDropDown 无法正确显示在控件的下发,总是遮住控件
class KtSearchGuidePop(context: Context) : BasePopWindow(context) {
override fun getAnimateView(): View = animateView
override fun getLayoutId(): Int = R.layout.pop_search_guide
override fun getBackDrawableColor(): Int = Color.TRANSPARENT
override fun isSupportBGDismiss(): Boolean = true
override fun showAsDropDown(anchor: View) {
if (Build.VERSION.SDK_INT >= 24) {
val rect = Rect()
anchor.getGlobalVisibleRect(rect)
val h = anchor.resources.displayMetrics.heightPixels - rect.bottom
height = h
}
super.showAsDropDown(anchor)
}
override fun showAsDropDown(anchor: View, xoff: Int, yoff: Int) {
if (Build.VERSION.SDK_INT >= 24) {
val rect = Rect()
anchor.getGlobalVisibleRect(rect)
val h = anchor.resources.displayMetrics.heightPixels - rect.bottom
height = h
}
super.showAsDropDown(anchor, xoff, yoff)
}
override fun initPop(context: Context?, layoutId: Int) {
super.initPop(context, layoutId)
RxUtil.click(parent){
dismissAfterAnimation()
}
}
}