Open chenxi2035 opened 5 years ago
遇到了同样的问题,我的解决方法是手动计算RectF而不是通过anchorView
/**
* 调试时发现跳过测量RectF了ViewPage导致计算错误,所以直接计算出屏幕上的RectF
*/
val anchorRect = RectF()
val outLocation = IntArray(2)
anchorView.getLocationOnScreen(outLocation)
anchorRect.left = outLocation[0].toFloat()
anchorRect.top = outLocation[1].toFloat()
anchorRect.right = anchorRect.left + anchorView.measuredWidth
anchorRect.bottom = anchorRect.top + anchorView.measuredHeight
val guidePage = GuidePage.newInstance()
.addHighLightWithOptions(anchorRect, HighLight.Shape.ROUND_RECTANGLE, dp2px(10), options)
//added by isanwenyu@163.com fix bug #21 the wrong rect user will received in ViewPager if (tmp.getParent() != null && (tmp.getParent() instanceof ViewPager)) { tmp = (View) tmp.getParent(); }
ViewUtils中的这句代码,有些莫名奇妙,导致在指定自己的anchor时,位置计算时跳过了viewpager,跑到acitvity层的decorView了。