setOnLayoutCallback 会执行两次
clj12081103 opened this issue · 3 comments
clj12081103 commented
如题
DuShuYuan commented
同问,怎么解决
lusongcai commented
.anchor(getActivity().findViewById(R.id.container))//如果是Activity上增加引导层,不需要设置anchor
注释掉就行了
wxz-wander commented
public HighLight(Context context) {
mContext = context;
mViewRects = new ArrayList<>();
mAnchor = ((Activity) mContext).findViewById(android.R.id.content);
mListenersHandler = new ListenersHandler(this);
registerGlobalLayoutListener();
}
public HighLight anchor(View anchor) {
mAnchor = anchor;
registerGlobalLayoutListener();
return this;
}
在activity使用的时候,构造方法,和anchor都会去注册布局监听,导致会重复注册,所以在acitivty使用引导层,就不设置anchor。同意楼上@lusongcai