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

突然没有显示,一片空白 #9

Open
jingquanxie opened this issue Mar 8, 2018 · 3 comments
Open

突然没有显示,一片空白 #9

jingquanxie opened this issue Mar 8, 2018 · 3 comments

Comments

@jingquanxie
Copy link

在页面静止时很正常很好,但是经历一次activity切换就会没有任何数据了。

@oubowu
Copy link
Owner

oubowu commented Mar 8, 2018

有可能是scroller在页面不可见后 computeScroll 这个方法走不进去了 后面我也处理了一下 切换回来会有短暂的无数据 然后又正常显示了 你现在测试的是最新的代码吗

@jingquanxie
Copy link
Author

嗯,是最新的,昨天才检出的,

@jingquanxie
Copy link
Author

还有个问题,就是和我前面同样的操作,有时候会出现不滚动了。不知道是不是我改了一个地方的原因

if (getChildCount() > 0) {
for (int i = 0; i < getChildCount(); i++) {
final View child = getChildAt(i);
// 获取子元素的布局参数
final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
// 测量子元素并考虑外边距
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
// 计算父容器的期望值
parentDesireWidth = child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;
// 取子控件最大宽度
tmpWidth = Math.max(tmpWidth, parentDesireWidth);
parentDesireHeight = child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin;
// 取子控件最大高度
tmpHeight = Math.max(tmpHeight, parentDesireHeight);
}
parentDesireWidth = tmpWidth;
parentDesireHeight = tmpHeight;
// 考虑父容器内边距
parentDesireWidth += getPaddingLeft() + getPaddingRight();
parentDesireHeight += getPaddingTop() + getPaddingBottom();
// Log.e("TAG", "MarqueeLayout-100行-onMeasure(): " + parentDesireWidth + ";" + parentDesireHeight + ";" + getSuggestedMinimumWidth() + ";" + getSuggestedMinimumHeight());
// 尝试比较建议最小值和期望值的大小并取大值
parentDesireWidth = Math.max(parentDesireWidth, getSuggestedMinimumWidth());
parentDesireHeight = Math.max(parentDesireHeight, getSuggestedMinimumHeight());
}

我把这个改成了>0 之前是>=0这样h会导致只有一条的时候无法滚动

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

No branches or pull requests

2 participants