Android横向水平智能刷新框架-SmartRefreshHorizontal

网友投稿 1080 2022-10-24

Android横向水平智能刷新框架-SmartRefreshHorizontal

Android横向水平智能刷新框架-SmartRefreshHorizontal

Android横向智能刷新框架-SmartRefreshHorizontal

English | 中文

SmartRefreshHorizontal 作为 SmartRefreshLayout 的扩展库,实现了横向刷新和加载的功能, 虽然是独立的开源库,但是并没有重复做实现, 而是对 SmartRefreshLayout 做了封装和转换,使其支持横向刷新。 所以 SmartRefreshHorizontal 继承了 SmartRefreshLayout 所有的特性,只是方向改成了横向。

特点:

支持 横向滚动支持 SmartRefreshLayout 的所有特性支持 AndroidX

由来

SmartRefreshLayout 的设计灵活多样,扩展性高,我想这应该是它受欢迎的原因之一。 在 issue 区有不少人建议让 SmartRefreshLayout 支持横向刷新。 其实大家都知道横向刷新的库已经有了不少,我给他们的回复是使用其他现有的横向刷新库。 但这在 issue 引发热议,可能是那些横向刷新库的使用、功能、扩展与 SmartRefreshLayout有很大差距。 所以我自己认为要做横向刷新库也需要能够像 SmartRefreshLayout 一样的多功能与易扩展。 如果直接扩展 SmartRefreshLayout 的功能使其直接支持横向,将会增加代码量。 然而当此时它已经足够庞大,并且也有不少人抱怨它太大需要分包细化功能。所以一开始的时候我几乎没有开发横向刷新功能的想法。 因为用到横向刷新的应用场景比竖向刷新少很多,我自己也很少会用到这样的场景。 如果为了实现一个我自己不常用的功能库要花费我太多时间和精力实在划不来,仅仅实现一个简单的横向刷新又没有必要...

原理

终于!有一天我在开发旋转动画过程中,产生了一个奇妙的想法:如果把 SmartRefreshLayout 旋转90度会怎样? 然后开始做试验:把 SmartRefreshLayout 旋转90度,再把 Content 旋转-90度。结果竟然真的可以用!! 这样就不用让我花大量时间精力去做横向刷新代码实现,SmartRefreshLayout 原有的所有功能多可以直接使用, 之前设计的十多个 Header 和 Footer 也可以不用任何修改直接使用!这让我产生了开发横向刷新库的动力。 于是基于这个试验想法就诞生了这个 SmartRefreshHorizontal 库 !

明白了 SmartRefreshHorizontal 与 SmartRefreshLayout 的关系,那么大家在使用本库的使用同时也要依赖 SmartRefreshLayout,并且版本要大于 1.1.0-beta-1 ,否则会出现找不到类的错误。

传送门

属性文档常见问题更新日志博客文章源码-自定义Header

Demo

- APK-Demo

效果演示

简单用例

1. 在 build.gradle 中添加依赖

//2.x implementation 'com.scwang.smart:refresh-layout-horizontal:2.0.0' implementation 'com.scwang.smart:refresh-layout-kernel:2.0.1' implementation 'com.scwang.smart:refresh-header-classics:2.0.1' //经典刷新头 implementation 'com.scwang.smart:refresh-header-material:2.0.1' //谷歌刷新头 //1.x implementation 'com.scwang.smartrefresh:SmartRefreshHorizontal:1.1.2' implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.3' //必须依赖 版本 1.1.0 以上 //androidx implementation 'com.scwang.smartrefresh:SmartRefreshHorizontal:1.1.2-x' implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.3' //必须依赖 版本 1.1.0 以上

2. 在XML布局文件中添加 SmartRefreshHorizontal

3. 在 Activity 或者 Fragment 中添加代码

RefreshLayout refreshLayout = root.findViewById(R.id.refreshLayout); refreshLayout.setRefreshHeader(new MaterialHeader(root.getContext())); refreshLayout.setRefreshFooter(new RefreshFooterWrapper(new MaterialHeader(root.getContext())), -1, -2);

混淆

SmartRefreshHorizontal 不需要添加混淆过滤代码,并且已经混淆测试通过,如果你在项目的使用中混淆之后出现问题,请及时通知我。

其他作品

MultiWaveHeader SmartRefreshLayout 诗和远方

License

Copyright 2019 scwang90Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:686. Repeated String Match
下一篇:337. House Robber III
相关文章

 发表评论

暂时没有评论,来抢沙发吧~