hongyangAndroid/Highlight

setOnLayoutCallback 会执行两次

clj12081103 opened this issue · 3 comments

如题

同问,怎么解决

.anchor(getActivity().findViewById(R.id.container))//如果是Activity上增加引导层,不需要设置anchor
注释掉就行了

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