这个组件类似于 SwipeRefreshLayout,它比 SwipeRefreshLayout 更美观。
这个组件类似于 SwipeRefreshLayout,它比 SwipeRefreshLayout 更美观。
android-PullRefreshLayout ======================== 这个组件类似于 SwipeRefreshLayout,它比 SwipeRefreshLayout 更美观。 # Demo
# 使用 1. 添加依赖。
dependencies { compile 'com.baoyz.pullrefreshlayout:library:1.2.0' } 2. 使用方法与 SwipeRefreshLayout 的使用方法相同。 3. 在布局 xml 中使用它。 ```xml
<com.baoyz.widget.PullRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.baoyz.widget.PullRefreshLayout>
4. 获取实例并使用它。java
PullRefreshLayout layout = (PullRefreshLayout) findViewById(...);
// listen refresh event layout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { // start refresh } });
// refresh complete layout.setRefreshing(false);
5. 更改刷新样式,共有五种样式可用,分别是 `MATERIAL`、`CIRCLES`、 `WATER_DROP`、`RING` 和 `SMARTISAN`。 6. 在 Java 中调用 `setRefreshStyle` 方法。java
layout.setRefreshStyle(PullRefreshLayout.STYLE_CIRCLES);
7. 在 xml 中使用属性。xml
<com.baoyz.widget.PullRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:refreshType="water_drop">
</com.baoyz.widget.PullRefreshLayout>
8. 更改颜色方案。 在 Java 中调用 `setColorSchemeColors` 方法。 int 数组的长度必须为 4。java
layout.setColorSchemeColors(int []);
对于 Smartisan 样式,它只有一种颜色,可以调用 `setColor()` 方法来设置一种颜色。暂无开放 Issues,或尚未同步最近议题。