├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── android │ │ └── yzl │ │ └── pulllefttorefreshlayout │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── android │ │ │ └── yzl │ │ │ └── pulllefttorefreshlayout │ │ │ ├── HorizontalScrollViewActivity.java │ │ │ ├── MainActivity.java │ │ │ └── RecyclerViewActivity.java │ └── res │ │ ├── layout │ │ ├── activity_horizontal.xml │ │ ├── activity_main.xml │ │ ├── activity_recycler.xml │ │ └── item_pull_left.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── android │ └── yzl │ └── pulllefttorefreshlayout │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── image └── UI.gif ├── lib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── android │ │ └── yzl │ │ └── lib │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── android │ │ │ └── yzl │ │ │ └── lib │ │ │ ├── AnimView.java │ │ │ ├── OnScrollListener.java │ │ │ └── PullLeftToRefreshLayout.java │ └── res │ │ ├── drawable-xxhdpi │ │ └── arrow.png │ │ ├── layout │ │ └── item_load_more.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── android │ └── yzl │ └── lib │ └── ExampleUnitTest.java ├── projectFilesBackup └── .idea │ └── workspace.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | PullLeftToRefreshLayout -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.8 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PullLeftToRefreshLayout 2 | 带有贝塞尔曲线效果的横向刷新布局,支持多种view,如RecyclerView,HorizontalScrollView等。 3 | ![image](https://github.com/yzl520/PullLeftToRefreshLayout/raw/master/image/UI.gif) 4 | #XML布局 5 | ``` 6 | 13 | 14 | 18 | 19 | 20 | ``` 21 | #自定义属性 22 | ``` 23 | app:footerBgColor="@color/yellow" 24 | ``` 25 | 可以改变刷新区域的背景颜色 26 | #监听事件 27 | ###刷新监听:当左拉距离达到刷新距离,且动画结束时调用。 28 | ``` 29 | PullLeftToRefreshLayout refreshLayout = (PullLeftToRefreshLayout) findViewById(R.id.plrl); 30 | refreshLayout.setOnRefreshListener(new PullLeftToRefreshLayout.OnRefreshListener() { 31 | @Override 32 | public void onRefresh() { 33 | Toast.makeText(RecyclerViewActivity.this, "刷新数据成功", Toast.LENGTH_SHORT).show(); 34 | } 35 | }); 36 | ``` 37 | ###滑动监听:当需要与其他可滑动控件(如ListView)嵌套使用时调用。 38 | ``` 39 | refreshLayout.setOnScrollListener(new OnScrollListener() { 40 | @Override 41 | public void onScrollChange(boolean scroll) { 42 | mListView.requestDisallowInterceptTouchEvent(scroll); 43 | } 44 | }); 45 | ``` 46 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.android.yzl.pulllefttorefreshlayout" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.4.0' 26 | compile 'com.android.support:recyclerview-v7:23.0.0' 27 | compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.0@aar' 28 | compile project(':lib') 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\dev\andorid_sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/android/yzl/pulllefttorefreshlayout/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.android.yzl.pulllefttorefreshlayout; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/yzl/pulllefttorefreshlayout/HorizontalScrollViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.android.yzl.pulllefttorefreshlayout; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.Toast; 7 | 8 | import com.android.yzl.lib.PullLeftToRefreshLayout; 9 | 10 | /** 11 | * Created by yzl on 2016/6/6. 12 | */ 13 | public class HorizontalScrollViewActivity extends AppCompatActivity { 14 | 15 | @Override 16 | protected void onCreate(@Nullable Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_horizontal); 19 | PullLeftToRefreshLayout plrl = (PullLeftToRefreshLayout) findViewById(R.id.plrl); 20 | plrl.setOnRefreshListener(new PullLeftToRefreshLayout.OnRefreshListener() { 21 | @Override 22 | public void onRefresh() { 23 | Toast.makeText(HorizontalScrollViewActivity.this, "刷新数据成功", Toast.LENGTH_SHORT).show(); 24 | } 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/yzl/pulllefttorefreshlayout/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.android.yzl.pulllefttorefreshlayout; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.Toast; 12 | 13 | import com.android.yzl.lib.PullLeftToRefreshLayout; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | 22 | } 23 | 24 | public void clickH(View v){ 25 | startActivity(new Intent(this, HorizontalScrollViewActivity.class)); 26 | } 27 | 28 | public void clickR(View v){ 29 | startActivity(new Intent(this, RecyclerViewActivity.class)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/android/yzl/pulllefttorefreshlayout/RecyclerViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.android.yzl.pulllefttorefreshlayout; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.Toast; 11 | 12 | import com.android.yzl.lib.PullLeftToRefreshLayout; 13 | 14 | /** 15 | * Created by yzl on 2016/6/6. 16 | */ 17 | public class RecyclerViewActivity extends AppCompatActivity { 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_recycler); 23 | 24 | RecyclerView rv = (RecyclerView) findViewById(R.id.rv); 25 | rv.setAdapter(new PullAdapter()); 26 | rv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); 27 | 28 | PullLeftToRefreshLayout plrl = (PullLeftToRefreshLayout) findViewById(R.id.plrl); 29 | plrl.setOnRefreshListener(new PullLeftToRefreshLayout.OnRefreshListener() { 30 | @Override 31 | public void onRefresh() { 32 | Toast.makeText(RecyclerViewActivity.this, "刷新数据成功", Toast.LENGTH_SHORT).show(); 33 | } 34 | }); 35 | } 36 | 37 | public class PullAdapter extends RecyclerView.Adapter{ 38 | 39 | @Override 40 | public PullrHolder onCreateViewHolder(ViewGroup parent, int viewType) { 41 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pull_left, parent, false); 42 | return new PullrHolder(view); 43 | } 44 | 45 | @Override 46 | public void onBindViewHolder(PullrHolder holder, int position) { 47 | 48 | } 49 | 50 | @Override 51 | public int getItemCount() { 52 | return 10; 53 | } 54 | 55 | public class PullrHolder extends RecyclerView.ViewHolder{ 56 | 57 | public PullrHolder(View itemView) { 58 | super(itemView); 59 | } 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_horizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 18 | 19 | 27 | 28 | 36 | 37 | 45 | 46 | 54 | 55 | 63 | 64 | 72 | 73 | 81 | 82 | 90 | 91 | 99 | 100 | 108 | 109 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |