Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在Fragment中使用出现SildeBottomPanel位移了 #10

Open
huangyanbin opened this issue Mar 3, 2016 · 4 comments
Open

在Fragment中使用出现SildeBottomPanel位移了 #10

huangyanbin opened this issue Mar 3, 2016 · 4 comments
Labels

Comments

@huangyanbin
Copy link

多个fragment切换的时候SlideBottomPandel会出现位移,黑影。跟踪发现在onMeasure,onLayout重新布局导致。

@smay1227
Copy link

smay1227 commented Jul 6, 2016

我也遇到了,你解决了吗

@huangyanbin
Copy link
Author

我在切换fragment,然后控制不调用onMeasure方法。

@smay1227
Copy link

smay1227 commented Jul 6, 2016

你是怎样控制的,我这样写会有错, 我看了一下onMeasure里的两个参数,在fragment切换时是不变的。
@OverRide
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Log.i(SlideBottomPanel.TAG, "isViewPageChanging " + isViewPageChanging);
if (!isViewPageChanging){
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
mMeasureHeight = getMeasuredHeight();
Log.i(SlideBottomPanel.TAG, "mMeasureHeight: " + mMeasureHeight);
}
}

@huangyanbin
Copy link
Author

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {

    if(isKeepLayout && !isFirst){
        return;
    }
    isFirst = false;
    super.onLayout(changed, left, top, right, bottom);
    mChildCount = getChildCount();
    int t = (int) (mMeasureHeight - mTitleHeightNoDisplay);
    for (int i = 0; i < mChildCount; i++) {
        View childView = getChildAt(i);
        if (childView.getTag() == null || (int) childView.getTag() != TAG_BACKGROUND) {
            childView.layout(0, t, childView.getMeasuredWidth(), childView.getMeasuredHeight() + t);
            childView.setTag(TAG_PANEL);
        } else if (childView.getTag() == TAG_BACKGROUND){
            childView.layout(0, 0, childView.getMeasuredWidth(), childView.getMeasuredHeight());
            childView.setPadding(0, 0, 0, (int)mTitleHeightNoDisplay);
        }
    }
}


@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if(isKeepLayout&& !isFirst){
        return;
    }
    mMeasureHeight = getMeasuredHeight();

}

我在切换的和OnResume方法时候调用
public void setKeepLayout() {
isKeepLayout = true;
this.postDelayed(new Runnable() {
@OverRide
public void run() {
isKeepLayout = false;
}
},200);
}
没办法,这个bug好难堵住

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants