您的位置:首页 > 其它

Materialrefreshlibrary使用中的一个bug

2017-02-14 00:00 197 查看
摘要: 比SwipeRefreshLayout更漂亮和强大的下拉刷新控件:Android-MaterialRefreshLayout

Materialrefreshlibrary 地址 https://github.com/android-cjj/Android-MaterialRefreshLayout
这个是git上别人写的。下载下来后,运行没什么问题。不过用到我的项目上有个bug。fragment切换时加载的圆圈会出现,而且是叠加在一起,就是切换几次就叠加几个圆圈。后面查看源码才发现。只要在头尾headerview里面的onAttachedToWindow方法设置下就可以了。以此记录。代码如下:

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();

final float density = getContext().getResources().getDisplayMetrics().density;

materialWaveView = new MaterialWaveView(getContext());
materialWaveView.setColor(waveColor);
addView(materialWaveView);

circleProgressBar = new CircleProgressBar(getContext());
LayoutParams layoutParams = new LayoutParams((int) density * progressSize, (int) density * progressSize);
layoutParams.gravity = Gravity.CENTER;
circleProgressBar.setLayoutParams(layoutParams);
circleProgressBar.setColorSchemeColors(progress_colors);
circleProgressBar.setProgressStokeWidth(progressStokeWidth);
circleProgressBar.setShowArrow(isShowArrow);
circleProgressBar.setShowProgressText(textType == 0);
circleProgressBar.setTextColor(progressTextColor);
circleProgressBar.setProgress(progressValue);
circleProgressBar.setMax(progressValueMax);
circleProgressBar.setCircleBackgroundEnabled(isShowProgressBg);
circleProgressBar.setProgressBackGroundColor(progressBg);
addView(circleProgressBar);
//添加了这一句。bug解决
circleProgressBar.setVisibility(GONE);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息