Android????????-SmartRefreshLayout
English | ??
???????SmartRefreshLayout???“??”??“??”????????????“??”??????????View??????????????????ViewGroup ???FrameLayout?LinearLayout??????? ?????????????????????????? SwipeRefreshLayout??????? Ultra-Pull-To-Refresh? TwinklingRefreshLayout ?????????? Header ? Footer?
SmartRefreshLayout??????????????????????????????????????????Header?Footer?
????:
- ??????
- ???????????
- ????? View?AbsListView?RecyclerView?WebView....View?
- ????????????????? Header ? Footer.
- ???ListView??????? ? CoordinatorLayout ????? .
- ????????????????????????????????????.
- ?????????????????????????.
- ??????????????App??????????????.
- ????????????????????????????
- ??????????????
???
Demo
????
???? | ???? |
---|---|
???? | ???? |
---|---|
???? Style
Delivery | Dropbox |
---|---|
Refresh-your-delivery | Dropbox-Refresh |
???????????????????github??????Header?????????????
BezierRadar | BezierCircle |
---|---|
Pull To Refresh | Pull Down To Refresh |
FlyRefresh | Classics |
---|---|
FlyRefresh | ClassicsHeader |
Phoenix | Taurus |
---|---|
Yalantis/Phoenix | Yalantis/Taurus |
BattleCity | HitBlock |
---|---|
FunGame/BattleCity | FunGame/HitBlock |
WaveSwipe | Material |
---|---|
WaveSwipeRefreshLayout | MaterialHeader |
StoreHouse | WaterDrop |
---|---|
Ultra-Pull-To-Refresh | WaterDrop |
????????Header?????????????????????Header??????????????????????????????????
?????????????????????????????????
- SmartRefreshLayout ???????????ClassicsHeader?????BezierRadarHeader????????? Header.
- SmartRefreshHeader ??Header??????Layout???Header?????????.
- SmartRefreshFooter ??Footer??????Layout???Footer?????????.
????
1.? buld.gradle ?????
//??????-??bug????????? 1.0.3 ?? compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-alpha-12' compile 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.4-alpha-12'//??????Header??????? compile 'com.android.support:appcompat-v7:25.3.1'//???????? compile 'com.android.support:design:25.3.1'//?????????????????????? //??? compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.3' compile 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.3'//??????Header???????
2.?XML??????? SmartRefreshLayout
<?xml version="1.0" encoding="utf-8"?> <com.scwang.smartrefresh.layout.SmartRefreshLayout 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:background="#fff" /> </com.scwang.smartrefresh.layout.SmartRefreshLayout>
3.? Activity ?? Fragment ?????
RefreshLayout refreshLayout = (RefreshLayout)findViewById(R.id.refreshLayout);
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
refreshlayout.finishRefresh(2000);
}
}
);
refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {
@Override
public void onLoadmore(RefreshLayout refreshlayout) {
refreshlayout.finishLoadmore(2000);
}
}
);
????? Header ? Footer
1.??? ????
public class App extends Application {
//static ???????????
static {
//?????Header???
SmartRefreshLayout.setDefaultRefreshHeaderCreater(new DefaultRefreshHeaderCreater() {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
layout.setPrimaryColorsId(R.color.colorPrimary, android.R.color.white);
//????????
return new ClassicsHeader(context).setTimeFormat(new DynamicTimeFormat("??? %s"));
//?????Header???? ?????Header
}
}
);
//?????Footer???
SmartRefreshLayout.setDefaultRefreshFooterCreater(new DefaultRefreshFooterCreater() {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
//?????Footer???? BallPulseFooter
return new ClassicsFooter(context).setDrawableSize(20);
}
}
);
}
}
?????? ???Header?Footer????????????????????????????????
2.??? XML??????
<com.scwang.smartrefresh.layout.SmartRefreshLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#444444"
app:srlPrimaryColor="#444444"
app:srlAccentColor="@android:color/white"
app:srlEnablePreviewInEditMode="true">
<!--srlAccentColor srlPrimaryColor ???? Header ? Footer ?????-->
<!--srlEnablePreviewInEditMode ???????????-->
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/padding_common"
android:background="@android:color/white"
android:text="@string/description_define_in_xml"/>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"/> </com.scwang.smartrefresh.layout.SmartRefreshLayout>
?????? XML???Header?Footer????????????????????????????Android Studio ???????????
???????????????????????????~
3.??? Java????
final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
//?? Header ? Material?? refreshLayout.setRefreshHeader(new MaterialHeader(this).setShowBezierWave(true));
//?? Footer ? ??? refreshLayout.setRefreshFooter(new BallPulseFooter(this).setSpinnerStyle(SpinnerStyle.Scale));
??
SmartRefreshLayout ???????????????JNI????????????????????????????????????????????????????????
??
????? SmartRefreshLayout ?????? SmartRefreshLayout ???????????? "Star" ???? ??? ^_^
?????????????~ ?????????
??????????????????????~ ?????github????????????github?????????????????????????????????
????
??
QQ??? - 602537182 ????
????
???????????????????????????????????????????Bug????????????? ?????????????????????????????????????bug??????????????????? ?????????????????????????????????????????????????????????? ??????????????????bug????????????????????bug?? ?????????????????????????????????????????????????????????? ???QQ????
QQ??? - 538979188 ??? 477963933 ???
????
?????????????????????????????????????????????????????????? ????????????????????????????Bug????????????????????????????? ????????????????????????????????????????????????????????
????
???????????????~
??
SwipeRefreshLayout
Ultra-Pull-To-Refresh
TwinklingRefreshLayout
BeautifulRefreshLayout
License
Copyright 2017 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.