SmartRefreshLayout源码分析
来源:互联网 发布:nginx java应用 编辑:程序博客网 时间:2024/05/22 12:21
先看看基本功能:BasicUsingActivity
布局文件:
<com.scwang.smartrefresh.layout.SmartRefreshLayout android:id="@+id/refreshLayout" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" tools:listitem="@android:layout/simple_list_item_2"/> <com.scwang.smartrefresh.layout.footer.ClassicsFooter android:layout_width="match_parent" android:layout_height="wrap_content" app:srlClassicsSpinnerStyle="Translate"/></com.scwang.smartrefresh.layout.SmartRefreshLayout>
默认的hearder是
ClassicsHeader
static { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); SmartRefreshLayout.setDefaultRefreshHeaderCreater(new DefaultRefreshHeaderCreater() { @NonNull @Override public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) { layout.setPrimaryColorsId(R.color.colorPrimary, android.R.color.white);//全局设置主题颜色 return new ClassicsHeader(context).setSpinnerStyle(SpinnerStyle.Translate); } });}
listview 要包裹一层
mRefreshContent = new RefreshContentWrapper(view);
把listview放在最前边:
bringChildToFront(mRefreshContent.getView());
先了解一下NestedScrollingParent
http://blog.csdn.net/lmj623565791/article/details/52204039
https://github.com/hongyangAndroid/Android-StickyNavLayout
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed){ // Log.e(TAG, "onNestedPreScroll"); Log.d(TAG, "dx = [" + dx + "], dy = [" + dy + "], consumed = [" + consumed + "]"); boolean hiddenTop = dy > 0 && getScrollY() < mTopViewHeight; //向上滑动 boolean showTop = dy < 0 && getScrollY() >= 0 && !ViewCompat.canScrollVertically(target, -1); //向下滑动 ,recyclerview如果不能向下滑动,就会展示top if (hiddenTop || showTop) { scrollBy(0, dy); consumed[1] = dy; }}
@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){ //不限制顶部的高度 Log.d(TAG, "onMeasure: "); super.onMeasure(widthMeasureSpec, heightMeasureSpec); getChildAt(0).measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); ViewGroup.LayoutParams params = mViewPager.getLayoutParams(); params.height = getMeasuredHeight() - mNav.getMeasuredHeight(); //mViewPager.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(params.height,MeasureSpec.EXACTLY));//我自己加的super.onMeasure(widthMeasureSpec, heightMeasureSpec);//我自己加的,和上边一行的二选一setMeasuredDimension(getMeasuredWidth(), mTop.getMeasuredHeight() + mNav.getMeasuredHeight() + mViewPager.getMeasuredHeight());}
https://github.com/race604/FlyRefresh
树干是用path 实现的,画的是轮廓。
阅读全文
0 0
- SmartRefreshLayout源码分析
- SmartRefreshLayout
- SmartRefreshLayout
- SmartRefreshLayout的使用
- Android SmartRefreshLayout的使用
- SmartRefreshLayout---“智能”下拉刷新布局
- SmartRefreshLayout 够炫,够cool
- 源码分析
- 源码分析
- 源码分析
- 源码分析
- 源码分析
- 源码分析
- 源码分析
- 源码分析
- Android智能下拉刷新框架-SmartRefreshLayout
- Android 在使用SmartRefreshLayout遇到的点点滴滴
- Android智能下拉刷新框架-SmartRefreshLayout
- 设计模式之一----工厂模式
- 你不应该错过的 Android 全方位面试总结
- 节后荐书:Python、PyQt5、Kotlin(评论送书)
- Python安装中需要特别注意的一件事
- c++ vector 删除, map
- SmartRefreshLayout源码分析
- 63、java集合-HashSet
- Java中的static关键字解析
- HTML5表单新增元素和属性(1)
- C++ 编译错误cannot allocate an object of abstract type“xx”
- jsp+servlet文件上传
- hue快速入门--Hadoop可视化分析利
- Excel2013如何让数据按照小数点对齐方便观察数据大小
- 给你看八个网页特效,让你的网站建设更加引人入胜!