最近要实现如何如图效果:
主要是在初始化,代码如下:
private void setSwipeRefresh() {
TypedValue typed_value = new TypedValue(); this.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, typed_value, true);
refreshLayout.setProgressViewOffset(false, 0, getResources().getDimensionPixelSize(typed_value.resourceId));
refreshLayout.setRefreshing(true);
}
Activity如下:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ayout);
refreshLayout = (SwipeRefreshLayout) this.findViewById(R.id.refresh_layout);
refreshLayout.setOnRefreshListener(this);
setSwipeRefresh();
//设置颜色
refreshLayout.setColorSchemeResources(R.color.green,R.color.gray, R.color.blue_50, R.color.light_white);
}