android.view.animation.RotateAnimation#setInterpolator()源码实例Demo

下面列出了android.view.animation.RotateAnimation#setInterpolator() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
/**
 * 显示进度动画
 */
public void showProgressAnimation(ImageView view) {
    if (view == null) return;

    view.setVisibility(View.VISIBLE);
    RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    LinearInterpolator lin = new LinearInterpolator();
    rotate.setInterpolator(lin);
    rotate.setDuration(2000);
    rotate.setRepeatCount(-1);
    rotate.setFillAfter(true);

    view.setAnimation(rotate);

}
 
源代码3 项目: AndroidStudyDemo   文件: AnimationUtils.java
public static RotateAnimation initRotateAnimation(boolean isClockWise, long duration,
        boolean isFillAfter, int repeatCount) {
    int endAngle;
    if (isClockWise) {
        endAngle = 360;
    } else {
        endAngle = -360;
    }
    RotateAnimation mLoadingRotateAnimation = new RotateAnimation(0, endAngle,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    LinearInterpolator lirInterpolator = new LinearInterpolator();
    mLoadingRotateAnimation.setInterpolator(lirInterpolator);
    mLoadingRotateAnimation.setDuration(duration);
    mLoadingRotateAnimation.setFillAfter(isFillAfter);
    mLoadingRotateAnimation.setRepeatCount(repeatCount);
    mLoadingRotateAnimation.setRepeatMode(Animation.RESTART);
    return mLoadingRotateAnimation;
}
 
private void initView(Context context, AttributeSet attrs) {
    CircleProgressDrawable drawable = new CircleProgressDrawable();
    if (null != attrs) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, 0, 0);
        int arcColor = a.getColor(R.styleable.CircleProgressBar_color_arc, 0);
        int bgColor = a.getColor(R.styleable.CircleProgressBar_color_background, 0);
        float strokeWidth = a.getDimension(R.styleable.CircleProgressBar_stroke_width, 5.f);
        drawable.setStrokeWidth(strokeWidth);
        drawable.setArcColor(arcColor);
        drawable.setBackgroundColor(bgColor);
        a.recycle();
    }
    setImageDrawable(drawable);
    mAnimation = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimation.setDuration(800);
    mAnimation.setInterpolator(new LinearInterpolator());
    mAnimation.setRepeatCount(-1);
    mAnimation.setRepeatMode(RotateAnimation.RESTART);
    startAnimation(mAnimation);
}
 
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
源代码6 项目: sctalk   文件: RotateLoadingLayout.java
public RotateLoadingLayout(Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true);

	mHeaderImage.setScaleType(ScaleType.MATRIX);
	mHeaderImageMatrix = new Matrix();
	mHeaderImage.setImageMatrix(mHeaderImageMatrix);

	mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setRepeatCount(Animation.INFINITE);
	mRotateAnimation.setRepeatMode(Animation.RESTART);
}
 
源代码7 项目: MagicHeaderViewPager   文件: FlipLoadingLayout.java
public FlipLoadingLayout(Context context, final PullToRefreshBase.Mode mode, final PullToRefreshBase.Orientation scrollDirection, TypedArray attrs, int layoutId) {
    super(context, mode, scrollDirection, attrs, layoutId);

    final int rotateAngle=mode == PullToRefreshBase.Mode.PULL_FROM_START ? -180 : 180;

    mRotateAnimation=new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
    mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
    mRotateAnimation.setFillAfter(true);

    mResetRotateAnimation=
        new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
    mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
    mResetRotateAnimation.setFillAfter(true);
}
 
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
源代码9 项目: RefreashTabView   文件: FlipLoadingLayout.java
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
源代码10 项目: Social   文件: FlipLoadingLayout.java
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
源代码11 项目: UltimateAndroid   文件: PullToRefreshView.java
/**
 * init
 *
 * @param
 * @description
 */
private void init() {
    // Load all of the animations we need in code rather than through XML
    mFlipAnimation = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(-180, 0,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);

    mInflater = LayoutInflater.from(getContext());
    // header view 在此添加,保证是第一个添加到linearlayout的最上端
    addHeaderView();
}
 
源代码12 项目: CloudReader   文件: EverydayFragment.java
private void initAnimation() {
    bindingView.llLoading.setVisibility(View.VISIBLE);
    animation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(3000);//设置动画持续时间
    animation.setInterpolator(new LinearInterpolator());//不停顿
    animation.setRepeatMode(ValueAnimator.RESTART);//重新从头执行
    animation.setRepeatCount(ValueAnimator.INFINITE);//设置重复次数
    bindingView.ivLoading.setAnimation(animation);
    animation.startNow();
}
 
源代码13 项目: revolution-irc   文件: ExpandIconStateHelper.java
public static void animateSetExpanded(View view, boolean expanded) {
    view.setRotation(expanded ? 180.f : 0.f);
    int toDegrees = (expanded ? 0 : 360);
    RotateAnimation rotate = new RotateAnimation(180, toDegrees,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(250);
    rotate.setInterpolator(new AccelerateDecelerateInterpolator());
    view.startAnimation(rotate);
}
 
源代码14 项目: SprintNBA   文件: RotateImageView.java
/**
 * 设置动画效果
 */
private void setRotateAnimation() {
    if (mIsHasAnimation == false && getWidth() > 0 && getVisibility() == View.VISIBLE) {
        mIsHasAnimation = true;
        mAnimation = new RotateAnimation(0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        mAnimation.setDuration(1000L);
        mAnimation.setInterpolator(new LinearInterpolator());
        mAnimation.setRepeatCount(-1);
        mAnimation.setRepeatMode(Animation.RESTART);
        setAnimation(mAnimation);
    }
}
 
源代码15 项目: SmallGdufe-Android   文件: RefreshActionItem.java
public void startProgress(){
    if (mRefreshButton.getAnimation() != null)
        return;
    RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(500);
    rotateAnimation.setFillAfter(false);
    rotateAnimation.setRepeatCount(-1);
    rotateAnimation.setRepeatMode(Animation.RESTART);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    mRefreshButton.startAnimation(rotateAnimation);
}
 
源代码16 项目: android_tv_metro   文件: EmptyLoadingView.java
public void viewStartAnimation(ImageView view) {
	mProgressLayout.setVisibility(View.VISIBLE);
	mRotateAnim = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnim.setInterpolator(new LinearInterpolator());
	mRotateAnim.setRepeatCount(Animation.INFINITE);
	mRotateAnim.setDuration(800);
	// mRotateAnim.setFillAfter(false);
	view.startAnimation(mRotateAnim);
}
 
源代码17 项目: SwipeMenuAndRefresh   文件: IndicatorLayout.java
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
	super(context);
	mArrowImageView = new ImageView(context);

	Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
	mArrowImageView.setImageDrawable(arrowD);

	final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
	mArrowImageView.setPadding(padding, padding, padding, padding);
	addView(mArrowImageView);

	int inAnimResId, outAnimResId;
	switch (mode) {
		case PULL_FROM_END:
			inAnimResId = R.anim.slide_in_from_bottom;
			outAnimResId = R.anim.slide_out_to_bottom;
			setBackgroundResource(R.drawable.indicator_bg_bottom);

			// Rotate Arrow so it's pointing the correct way
			mArrowImageView.setScaleType(ScaleType.MATRIX);
			Matrix matrix = new Matrix();
			matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
			mArrowImageView.setImageMatrix(matrix);
			break;
		default:
		case PULL_FROM_START:
			inAnimResId = R.anim.slide_in_from_top;
			outAnimResId = R.anim.slide_out_to_top;
			setBackgroundResource(R.drawable.indicator_bg_top);
			break;
	}

	mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
	mInAnim.setAnimationListener(this);

	mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
	mOutAnim.setAnimationListener(this);

	final Interpolator interpolator = new LinearInterpolator();
	mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(interpolator);
	mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(interpolator);
	mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);

}
 
源代码18 项目: appcan-android   文件: EBounceViewHeader.java
public EBounceViewHeader(Context context, int type) {
    super(context);
    setWillNotDraw(true);
    setBackgroundColor(0);
    setFocusable(false);
    ESystemInfo intence = ESystemInfo.getIntence();
    int height = intence.mDefaultBounceHeight;
    RelativeLayout wapper = new RelativeLayout(context);
    wapper.setWillNotDraw(true);
    wapper.setBackgroundColor(0);
    wapper.setFocusable(false);
    RelativeLayout.LayoutParams wParm = new LayoutParams(-1, height);
    if (type == EViewEntry.F_BOUNCE_TYPE_TOP) {
        wParm.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    } else {
        wParm.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    }
    wapper.setLayoutParams(wParm);
    addView(wapper);

    wap = new RelativeLayout(context);
    wap.setId(F_WAP_ID);
    RelativeLayout.LayoutParams wm = new LayoutParams(-2, height);
    wm.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    wm.leftMargin = 30;
    wap.setLayoutParams(wm);

    mContent = new TextView(context);
    mContent.setId(F_CONTENT_ID);
    RelativeLayout.LayoutParams parmMsg = new LayoutParams(-2, -2);
    parmMsg.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mContent.setLayoutParams(parmMsg);
    mContent.setTextColor(textColor);
    mContent.setText(pullToReloadText);
    mContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize));
    mContent.setVisibility(GONE);
    wap.addView(mContent);

    mLevelContent = new TextView(context);
    RelativeLayout.LayoutParams parml = new LayoutParams(-2, -2);
    parml.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    parml.addRule(RelativeLayout.BELOW, F_CONTENT_ID);
    mLevelContent.setLayoutParams(parml);
    mLevelContent.setTextColor(textColor);
    mLevelContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize * 0.6));
    mLevelContent.setVisibility(GONE);
    wap.addView(mLevelContent);

    wapper.addView(wap);

    mProgress = new ProgressBar(context);
    mProgress.setIndeterminate(true);
    int use = height - 12;
    RelativeLayout.LayoutParams parmPro = new LayoutParams(use, use);
    parmPro.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmPro.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mProgress.setLayoutParams(parmPro);
    mProgress.setVisibility(GONE);
    wapper.addView(mProgress);

    mYAxisProgress = new YAxisImageView(context);
    int useY = height - 12;
    RelativeLayout.LayoutParams parmProY = new LayoutParams(useY, useY);
    parmProY.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmProY.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mYAxisProgress.setLayoutParams(parmProY);
    mYAxisProgress.setVisibility(GONE);
    wapper.addView(mYAxisProgress);

    mArrowImage = new ImageView(context);
    int useA = height - 12;
    RelativeLayout.LayoutParams parmImage = new LayoutParams(useA, useA);
    parmImage.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmImage.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mArrowImage.setLayoutParams(parmImage);
    Drawable icon = context.getResources().getDrawable(EResources.platform_myspace_pulltorefresh_arrow);
    mArrowImage.setImageDrawable(icon);
    mArrowImage.setVisibility(GONE);
    wapper.addView(mArrowImage);

    mAnimationUp = new RotateAnimation(-180, 0,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimationUp.setInterpolator(new AccelerateInterpolator());
    mAnimationUp.setDuration(250);
    mAnimationUp.setFillAfter(true);

    mAnimationDown = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimationDown.setInterpolator(new AccelerateInterpolator());
    mAnimationDown.setDuration(250);
    mAnimationDown.setFillAfter(true);
}
 
源代码19 项目: YiBo   文件: PullToRefreshListView.java
private void init(Context context) {
    // Load all of the animations we need in code rather than through XML
    mFlipAnimation = new RotateAnimation(0, 180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(180, 360,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);

    LayoutInflater mInflater = (LayoutInflater) context.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    mRefreshView = (LinearLayout) mInflater.inflate(
            R.layout.widget_pull_to_refresh_header, null);

    mRefreshViewText =
        (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
    mRefreshViewImage =
        (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
    mRefreshViewProgress =
        (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
    mRefreshViewLastUpdated =
        (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_updated_at);

    Theme theme = new Theme(context);
    mRefreshViewText.setTextColor(theme.getColor("content"));
    
    mRefreshViewImage.setMinimumHeight(50);
    mRefreshView.setOnClickListener(new OnClickRefreshListener());
    mRefreshOriginalTopPadding = mRefreshView.getPaddingTop();

    mRefreshState = TAP_TO_REFRESH;

    addHeaderView(mRefreshView);

    super.setOnScrollListener(this);

    measureView(mRefreshView);
    mRefreshViewHeight = mRefreshView.getMeasuredHeight();
}
 
源代码20 项目: Social   文件: IndicatorLayout.java
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
	super(context);
	mArrowImageView = new ImageView(context);

	Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
	mArrowImageView.setImageDrawable(arrowD);

	final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
	mArrowImageView.setPadding(padding, padding, padding, padding);
	addView(mArrowImageView);

	int inAnimResId, outAnimResId;
	switch (mode) {
		case PULL_FROM_END:
			inAnimResId = R.anim.slide_in_from_bottom;
			outAnimResId = R.anim.slide_out_to_bottom;
			setBackgroundResource(R.drawable.indicator_bg_bottom);

			// Rotate Arrow so it's pointing the correct way
			mArrowImageView.setScaleType(ScaleType.MATRIX);
			Matrix matrix = new Matrix();
			matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
			mArrowImageView.setImageMatrix(matrix);
			break;
		default:
		case PULL_FROM_START:
			inAnimResId = R.anim.slide_in_from_top;
			outAnimResId = R.anim.slide_out_to_top;
			setBackgroundResource(R.drawable.indicator_bg_top);
			break;
	}

	mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
	mInAnim.setAnimationListener(this);

	mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
	mOutAnim.setAnimationListener(this);

	final Interpolator interpolator = new LinearInterpolator();
	mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(interpolator);
	mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(interpolator);
	mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);

}