• Stars
    star
    482
  • Rank 88,179 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

横向刷新、水平刷新、RefreshLayout、OverScroll,Horizontal,基于SmartRefreshLayout的水平智能刷新

Android横向智能刷新框架-SmartRefreshHorizontal

License MinSdk JCenter Author

English | 中文

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

特点:

由来

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 ,否则会出现找不到类的错误。

传送门

Demo

下载 APK-Demo

效果演示

商品详情 ViewPager
数据演示

简单用例

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

<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smartrefresh.horizontal.SmartRefreshHorizontal xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/refreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:overScrollMode="never"
        android:orientation="horizontal"
        android:background="#fff" />
</com.scwang.smartrefresh.horizontal.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 scwang90

Licensed 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://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.

More Repositories

1

SmartRefreshLayout

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
Java
24,460
star
2

MultiWaveHeader

Wave,水波,Android 炫酷的多重水波纹 MultiWaveHeader
Java
1,733
star
3

gradle-docs

gradle 官方文档自译版
72
star
4

AndFrameWorks

AndFrame 是一个能够让你快速进行Android开发的开源框架,它能让你专注于真正重要的地方。使代码更加精简,使项目更加容易维护。使用AndFrame框架之后,相比原生的Android开发能够让你少些很多代码
Java
68
star
5

SmartRefreshControl

SmartRefreshControl 是 SmartRefreshLayout 的IOS版,和Android版在 理念 和 外观 上面保留相同的设计,但是由于 Android 和 IOS 两个系统的差别,IOS版本在功能使用和特性上与安卓版有所差别。
Objective-C
54
star
6

CodeMan

spring-dbutil-jsp-web 代码生成项目
HTML
17
star
7

Restful

Java
4
star
8

WifiProbe

Java
2
star
9

scwang90.github.io

个人主页
CSS
2
star
10

PoetryPlatformTool

在线字体图片管理
Java
2
star
11

DataStatisticsClient

Java
1
star
12

AndAddress

Java
1
star
13

AndFrame

Java
1
star
14

AndSoap

Java
1
star
15

DynamicJar

Java
1
star
16

PoetryDatabase

Java
1
star
17

AndJsoup

Java
1
star
18

WebAnalytics

Java
1
star
19

JavaTest

Java
1
star
20

AndAdvert

Java
1
star
21

DataStatistics

Java
1
star
22

PoetryConfig

基于小米结构化存储的poetry在线配置Java客户端
Java
1
star
23

AndCloud

Java
1
star
24

netdata-zh

netdata 中文版
JavaScript
1
star