MaterialRefreshLayout v1.4.0

﹏ヽ暗。殇╰゛Y 2022-06-07 23:08 181阅读 0赞

Android Gems

MaterialRefreshLayout v1.4.0

这是一个下拉刷新控件,它比SwipeRefreshLayout更漂亮和强大,使用也比较简单。支持android 3.0 以上。希望你喜欢,呵呵。

现在让我来说说他有多牛逼的功能吧,其实也就那样……gif图录制的很奇怪,建议真机查看,啊哈哈哈

(1)如果你喜欢官方的刷新效果,没问题,它也可以做到,这是一种侵入式的下拉刷新

gif_2Fcjj2.gif

(2)然而,有些人并不喜欢侵入刷新,或者说,需求需要的是非侵入刷新,没问题,同时,觉得上面的效果太单调了,好的,我们可以加个波浪形状的背景,就像下图所示

gif_2Fcjj1.gif

(3)如果这时候你想要侵入式的刷新,又要有波浪背景,也就是所有效果覆盖在内容之上的话,没问题,它还是可以做到的,呵呵……

gif_2Fcjj3.gif

(4)我知道你需要加载更多,本人还是不建议两者一起,你可以用这个,两者去组合RecyclerViewWithFooter,当然,这里也写了。

gif_2Fcjj4.gif

(5)自动下拉刷新也是很多人需要的,比如下图所示,当然也做了自动上拉刷新,具体看源码

gif_2Fcjj5.gif

(6)看久了你如果讨厌的话,我还增加了一种样式,如下图:

gif_2Fcjj6.gif

(7)如果需要覆盖的,也可以…….

gif_2Fcjj7.gif

用法

AS添加依赖库,这样就不用导入整个library库,Eclipse的用户导入library库,慢慢折腾吧!(因为我觉得如果不是环境不允许你用as的话,还是放弃eclipse吧,毕竟github上很多优秀的项目都是用as的,好吧我多嘴了…)

1.4版本的bug比较少,功能还行,你直接导入library,想改什么就改什么了,

  1. dependencies {
  2. compile 'com.cjj.materialrefeshlayout:library:1.3.0'//不建议在as直接导入这个 bug 多 还是直接用library ,自己修改也方便
  3. }

在你的layout xml.添加下面的代码

  1. <com.cjj.MaterialRefreshLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:id="@+id/refresh"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. >
  8. <...ListView or GridView or RecyclerView or ScrollView and more...>
  9. </com.cjj.MaterialRefreshLayout>

实例化它并设置监听,onrefresh是必须实现的,其他都是方法可选,为了代码可读性而设计……

  1. materialRefreshLayout = (MaterialRefreshLayout) findViewById(R.id...);
  2. materialRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() {
  3. @Override
  4. public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) {
  5. //下拉刷新...
  6. }
  7. @Override
  8. public void onRefreshLoadMore(MaterialRefreshLayout materialRefreshLayout) {
  9. //上拉刷新...
  10. }
  11. }
  12. // 结束下拉刷新...
  13. materialRefreshLayout.finishRefresh();
  14. // 结束上拉刷新...
  15. materialRefreshLayout.finishRefreshLoadMore();

配置

(1)如果你喜欢官方的刷新效果

687474703a2f2f7777772e61706b6275732e636f6d2f646174612f6174746163686d656e742f666f72756d2f3230313530392f31302f3137313333387938756673786a7273376b32727875332e6a7067

在xml中, 设置以下属性

  1. <com.cjj.MaterialRefreshLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:id="@+id/refresh"
  7. app:overlay="true"
  8. app:wave_show="false"
  9. >

在代码中是这样的:

  1. materialRefreshLayout.setIsOverLay(true);
  2. materialRefreshLayout.setWaveShow(false);

(2)如果你喜欢非侵入刷新

687474703a2f2f7777772e61706b6275732e636f6d2f646174612f6174746163686d656e742f666f72756d2f3230313530392f31302f31373133333669337837356437783474616478657a742e6a7067

在xml中, 设置以下属性

  1. <com.cjj.MaterialRefreshLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:id="@+id/refresh"
  7. app:overlay="false"
  8. app:wave_show="false"
  9. >

在代码中是这样的:

  1. materialRefreshLayout.setIsOverLay(false);
  2. materialRefreshLayout.setWaveShow(false);

(3)如果你觉得上面的效果太单调了,加个波浪形状的背景,就像下图所示

687474703a2f2f7777772e61706b6275732e636f6d2f646174612f6174746163686d656e742f666f72756d2f3230313530392f31302f3137313333396c76686b336e336834776b676b6764632e6a7067

在xml中, 设置以下属性

  1. <com.cjj.MaterialRefreshLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:id="@+id/refresh"
  7. app:overlay="false"
  8. app:wave_show="true"
  9. app:wave_color="@color/material_green"
  10. app:wave_height_type="normal" (higher)
  11. >

在java代码中是这样的:

  1. materialRefreshLayout.setWaveColor(0xffffffff);
  2. materialRefreshLayout.setIsOverLay(false);
  3. materialRefreshLayout.setWaveShow(true);

(4)你想要侵入式的刷新,又要有波浪背景,也就是所有效果覆盖在内容之上

687474703a2f2f7777772e61706b6275732e636f6d2f646174612f6174746163686d656e742f666f72756d2f3230313530392f31302f313731333334787464307870687361673477773467732e6a7067

  1. <com.cjj.MaterialRefreshLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:id="@+id/refresh"
  7. app:overlay="true"
  8. app:wave_show="true"
  9. app:wave_color="#90ffffff"
  10. app:progress_colors="@array/material_colors"
  11. app:wave_height_type="higher"
  12. >

在java代码中是这样的:

  1. materialRefreshLayout.setWaveColor(0xf90fffff);
  2. materialRefreshLayout.setIsOverLay(true);
  3. materialRefreshLayout.setWaveShow(true);

(5)其他…

687474703a2f2f7777772e61706b6275732e636f6d2f646174612f6174746163686d656e742f666f72756d2f3230313530392f31302f313731333431787267616d636839336d6164347063672e6a7067

  1. <com.cjj.MaterialRefreshLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:id="@+id/refresh"
  7. app:overlay="false"
  8. app:wave_show="false"
  9. app:progress_colors="@array/material_colors"
  10. app:wave_height_type="higher"
  11. app:progress_show_circle_backgroud="false"
  12. >

(6)上拉加载更多…

687474703a2f2f7777772e61706b6275732e636f6d2f646174612f6174746163686d656e742f666f72756d2f3230313530392f31362f3138303334307879707837367970656670647a6672662e706e67

  1. <com.cjj.MaterialRefreshLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:id="@+id/refresh"
  7. app:isLoadMore="true"
  8. >

在java代码中是这样的:

  1. materialRefreshLayout.setLoadMore(true);

(7)自动下拉刷新,自动上拉刷新.

在java代码中是这样的:

  1. materialRefreshLayout.autoRefresh();//drop-down refresh automatically
  2. materialRefreshLayout.autoRefreshLoadMore();// pull up refresh automatically

V 1.3.0

添加自动下拉刷新,自动上拉刷新.

V 1.2.1

添加上拉加载更多…

V 1.2.0

添加了可设置加载圆圈的大小,有两种模式可以选择,在xml配置属性app:progress_size_type=”normal”(big)和修复一些bug

V 1.1.0

一个全新的动画展示效果,减小了库的大小,很不幸的从支持api 8 升到 api 11 不过,也没多少人用2.x.x的手机了……

V 1.0.0

支持api 8,第一版本,啊哈哈……

最后

如果这些都没能满足你的需求的话,没问题,你可以去看看BeautifulRefreshLayout,我想,你可以找到一个专属于你的人…错了…是下拉刷新……

在GitHub follow 我就是对我最大的支持,呵呵: https://github.com/android-cjj.

关于我

感谢

lsjwzh/MaterialLoadingProgressBar

随意说说

刚建了个github小伙伴交流群(477826523),有兴趣的朋友可以加进来的…小小要求:github有至少7个关注者或者开源库有7颗星星的…

License

  1. The MIT License (MIT)
  2. Copyright (c) 2015 android-cjj
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.

发表评论

表情:
评论列表 (有 0 条评论,181人围观)

还没有评论,来说两句吧...

相关阅读

    相关 NC140 排序

    使用快速排序 视频讲解可以看这个 把快速排序讲得很清楚[https://www.bilibili.com/video/BV1it41167v2][https_www.bil