Android UI- PullToRrefresh自定义下拉刷新动画,android组件化开发

static final String LOG_TAG = “PullToRefresh-LoadingLayout”;

static final Interpolator ANIMATION_INTERPOLATOR = new LinearInterpolator();

private FrameLayout mInnerLayout;

protected final ImageView mHeaderImage;

protected final ProgressBar mHeaderProgress;

private boolean mUseIntrinsicAnimation;

private final TextView mHeaderText;

private final TextView mSubHeaderText;

protected final Mode mMode;

protected final Orientation mScrollDirection;

private CharSequence mPullLabel;

private CharSequence mRefreshingLabel;

private CharSequence mReleaseLabel;

public LoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {

super(context);

mMode = mode;

mScrollDirection = scrollDirection;

switch (scrollDirection) {

case HORIZONTAL:

LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_horizontal, this);

break;

case VERTICAL:

default:

// LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, this);

// 修改代码

LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_simple, this);

break;

}

mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner);

mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text);

mHeaderProgress = (ProgressBar) mInnerLayout.findViewById(R.id.pull_to_refresh_progress);

mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text);

mHeaderImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_image);

FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInnerLayout.getLayoutParams();

switch (mode) {

case PULL_FROM_END:

lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.TOP : Gravity.LEFT;

// Load in labels

mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label);

mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label);

mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label);

break;

case PULL_FROM_START:

default:

lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.BOTTOM : Gravity.RIGHT;

// Load in labels

mPullLabel = context.getString(R.string.pull_to_refresh_pull_label);

mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label);

mReleaseLa

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值