2023年7月15日发(作者:)
仿美团下拉刷新动画经常使⽤美团,感觉下拉刷新动画挺好玩的,抽空也做了⼀个,图⽚资源是⽹上获取,先看效果: 本⽂所实现的功能是在⽹上流传的下拉刷新框架(),然后修改⽽得的,只在分享经验,代码如下:82936373839464748495657585960package refresh_view;
import fersh.R;
import t;import ;import ;import ionDrawable;import Drawable;import le;import uteSet;import Inflater;import Event;import ;import oup;import Interpolator;import Animation;import rView;import iew;import Layout;import ssBar;import View;import ew;
public class PullToRefreshView extends LinearLayout{
private static final int PULL_TO_REFRESH = 2; private static final int RELEASE_TO_REFRESH = 3; private static final int REFRESHING = 4; private static final int PULL_UP_STATE = 0; private static final int PULL_DOWN_STATE = 1; private static final int HEADER_OFFERT = 20; private boolean enablePullTorefresh = true; private boolean enablePullLoadMoreDataStatus = true; private int mLastMotionY; private boolean mLock; private boolean isFooter; private View mHeaderView; private View mFooterView; private LayoutParams params; private AdapterView> mAdapterView; private ScrollView mScrollView; private int mHeaderViewHeight; private int mFooterViewHeight;
private ImageView mHeaderImageView; private ImageView mFooterImageView; private TextView mFooterTextView; private ProgressBar mFooterProgressBar; private LayoutInflater mInflater; private int mHeaderState; private int mFooterState; private int mPullState; private RotateAnimation mFlipAnimation; private RotateAnimation mReverseFlipAnimation; private OnFooterRefreshListener mOnFooterRefreshListener; private OnHeaderRefreshListener mOnHeaderRefreshListener; private float mCurrentDragPercent; private boolean isShow = false; private Drawable showDrawable;6667686976777879868788899697989959124125 private Drawable showDrawable;
public PullToRefreshView(Context context) { super(context); init(); }
public PullToRefreshView(Context context, AttributeSet attrs) { super(context, attrs); init(); }
private void init() { setOrientation(AL);
// Load all of the animations we need in code rather than through XML
mFlipAnimation = new RotateAnimation(0, -180,
VE_TO_SELF, 0.5f,
VE_TO_SELF, 0.5f);
erpolator(new LinearInterpolator());
ation(150); lAfter(true); mReverseFlipAnimation = new RotateAnimation(-180, 0,
VE_TO_SELF, 0.5f,
VE_TO_SELF, 0.5f);
erpolator(new LinearInterpolator());
ation(150);
lAfter(true);
mHeaderState = 2; mInflater = (getContext()); addHeaderView(); } /** * 头部刷新视图 */ private void addHeaderView() { mHeaderView = e(h_header, this, false);
mHeaderImageView = (ImageView) ewById(_to_refresh_image); measureView(mHeaderView); mHeaderViewHeight = suredHeight(); params = new LayoutParams(_PARENT, mHeaderViewHeight); gin = -(mHeaderViewHeight); addView(mHeaderView, params); }
private void measureView(View child) { Params p = outParams(); if (p == null) { p = new Params(_PARENT, _CONTENT); }
int childWidthSpec = ldMeasureSpec(0, 0 + 0, ); int lpHeight = ; int childHeightSpec; if (lpHeight > 0) { childHeightSpec = asureSpec(lpHeight, Y); } else { childHeightSpec = asureSpec(0, IFIED); } e(childWidthSpec, childHeightSpec); }
/** * 尾部刷新视图 */ private void addFooterView() {8648648648189190 private void addFooterView() { mFooterView = e(h_footer, this, false); mFooterImageView = (ImageView) ewById(_to_load_image); mFooterTextView = (TextView) ewById(_to_load_text); mFooterProgressBar = (ProgressBar) ewById(_to_load_progress);
measureView(mFooterView); mFooterViewHeight = suredHeight(); LayoutParams params = new LayoutParams(_PARENT, mFooterViewHeight); addView(mFooterView, params); }
@Override protected void onFinishInflate() { shInflate(); // footer view 鍦ㄦ
发布者:admin,转转请注明出处:http://www.yc00.com/news/1689429967a246907.html
评论列表(0条)