下面列出了android.view.animation.RotateAnimation#setFillAfter() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void initView(Context context) {
// Initial set header view height 0
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
mContainer = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.vw_header, null);
addView(mContainer, lp);
setGravity(Gravity.BOTTOM);
mArrowImageView = (ImageView) findViewById(R.id.header_arrow);
mHintTextView = (TextView) findViewById(R.id.header_hint_text);
mProgressBar = (ProgressBar) findViewById(R.id.header_progressbar);
mRotateUpAnim = new RotateAnimation(0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateUpAnim.setFillAfter(true);
mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateDownAnim.setFillAfter(true);
}
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();
}
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);
}
private void initView(Context context) {
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
mContainer = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.heaven7_xlistview_header, null);
addView(mContainer, lp);
setGravity(Gravity.BOTTOM);
mArrowImageView = (ImageView) findViewById(R.id.xlistview_header_arrow);
mHintTextView = (TextView) findViewById(R.id.xlistview_header_hint_textview);
mProgressBar = (ProgressBar) findViewById(R.id.xlistview_header_progressbar);
mRotateUpAnim = new RotateAnimation(0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateUpAnim.setFillAfter(true);
mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateDownAnim.setFillAfter(true);
}
public FlipLoadingLayoutFooter(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs)
{
super(context, mode, scrollDirection, attrs, true);
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 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);
}
private void init(Context context) {
mHeaderContainer = (RelativeLayout) findViewById(R.id.pull_to_refresh_header_content);
mArrowImageView = (ImageView) findViewById(R.id.pull_to_refresh_header_arrow);
mHintTextView = (TextView) findViewById(R.id.pull_to_refresh_header_hint_textview);
mArrowImageView.setScaleType(ScaleType.CENTER);
mArrowImageView.setImageResource(R.drawable.default_ptr_rotate);
float pivotValue = 0.5f; // SUPPRESS CHECKSTYLE
float toDegree = 720.0f; // SUPPRESS CHECKSTYLE
mRotateAnimation = new RotateAnimation(0.0f, toDegree,
Animation.RELATIVE_TO_SELF, pivotValue,
Animation.RELATIVE_TO_SELF, pivotValue);
mRotateAnimation.setFillAfter(true);
mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
mRotateAnimation.setRepeatCount(Animation.INFINITE);
mRotateAnimation.setRepeatMode(Animation.RESTART);
}
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 FlipLoadingLayout(Context context, com.handmark.pulltorefresh.library.PullToRefreshBase.Mode mode, com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation orientation, TypedArray typedarray)
{
super(context, mode, orientation, typedarray);
int i;
if (mode == com.handmark.pulltorefresh.library.PullToRefreshBase.Mode.PULL_FROM_START)
{
i = -180;
} else
{
i = 180;
}
d = new RotateAnimation(0.0F, i, 1, 0.5F, 1, 0.5F);
d.setInterpolator(c);
d.setDuration(150L);
d.setFillAfter(true);
e = new RotateAnimation(i, 0.0F, 1, 0.5F, 1, 0.5F);
e.setInterpolator(c);
e.setDuration(150L);
e.setFillAfter(true);
}
private void initView(Context context) {
// 初始情况,设置下拉刷新view高度为0
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, 0);
mContainer = (LinearLayout) LayoutInflater.from(context).inflate(
R.layout.xlistview_header, null);
addView(mContainer, lp);
setGravity(Gravity.BOTTOM);
mArrowImageView = (ImageView)findViewById(R.id.xlistview_header_arrow);
mHintTextView = (TextView)findViewById(R.id.xlistview_header_hint_textview);
mProgressBar = (ProgressBarCircularIndeterminate)findViewById(R.id.xlistview_header_progressbar);
mRotateUpAnim = new RotateAnimation(0.0f, -180.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateUpAnim.setFillAfter(true);
mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateDownAnim.setFillAfter(true);
}
/**
* 根据当前的状态来旋转箭头。
*/
public static void rotateArrow(ImageView arrow, boolean flag) {
float pivotX = arrow.getWidth() / 2f;
float pivotY = arrow.getHeight() / 2f;
float fromDegrees = 0f;
float toDegrees = 0f;
// flag为true则向下
if (flag) {
fromDegrees = 0f;
toDegrees = 180f;
} else {
fromDegrees = 180f;
toDegrees = 0f;
}
//旋转动画效果 参数值 旋转的开始角度 旋转的结束角度 pivotX x轴伸缩值
RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees,
pivotX, pivotY);
//该方法用于设置动画的持续时间,以毫秒为单位
animation.setDuration(200);
//动画终止时停留在最后一帧
animation.setFillAfter(true);
//启动动画
arrow.startAnimation(animation);
}
public static void rotateUp(View view) {
RotateAnimation rotate = new RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
LinearInterpolator lin = new LinearInterpolator();
rotate.setInterpolator(lin);
rotate.setDuration(200);
rotate.setRepeatCount(0);
rotate.setFillAfter(true);
rotate.setStartOffset(10);
view.startAnimation(rotate);
}
private void initAnimation() {
mUpAnim = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
mUpAnim.setDuration(150);
mUpAnim.setFillAfter(true);
mDownAnim = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
mDownAnim.setFillAfter(true);
}
/**
* 旋转 Rotate
*/
public static Animation getRotateAnimation(float fromDegrees,
float toDegrees, long durationMillis) {
RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
rotate.setDuration(durationMillis);
rotate.setFillAfter(true);
return rotate;
}
@Override
public void onExpansionToggled(boolean expanded) {
super.onExpansionToggled(expanded);
if (!HONEYCOMB_AND_ABOVE) {
return;
}
RotateAnimation rotateAnimation = new RotateAnimation(ROTATED_POSITION,
INITIAL_POSITION,
RotateAnimation.RELATIVE_TO_SELF, PIVOT_VALUE,
RotateAnimation.RELATIVE_TO_SELF, PIVOT_VALUE);
rotateAnimation.setDuration(DEFAULT_ROTATE_DURATION_MS);
rotateAnimation.setFillAfter(true);
mArrowExpandImageView.startAnimation(rotateAnimation);
}
private void initView(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.ReboundListView);
headerProgressBarEnabled = a
.getBoolean(
R.styleable.ReboundListView_ReboundListView_FooterProgressBarEnabled,
false);
headerArrowEnabled = a.getBoolean(
R.styleable.ReboundListView_ReboundListView_HeaderArrowEnabled,
false);
headerIconEnabled = a.getBoolean(
R.styleable.ReboundListView_ReboundListView_HeaderIconEnabled,
false);
headerTimeEnabled = a.getBoolean(
R.styleable.ReboundListView_ReboundListView_HeaderTimeEnabled,
false);
headerIconSrc = a
.getDrawable(R.styleable.ReboundListView_ReboundListView_HeaderIconSrc);
// 初始情况,设置下拉刷新view高度为0
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, 0);
mContentView = (LinearLayout) LayoutInflater.from(context).inflate(
R.layout.rebound_listview_header, null);
addView(mContentView, lp);
setGravity(Gravity.BOTTOM);
mHintTextView = (TextView) findViewById(R.id.rebound_listview_header_hint_textview);
mProgressBar = (ProgressBar) findViewById(R.id.rebound_listview_header_progressbar);
if (headerProgressBarEnabled) {
mProgressBar.setVisibility(VISIBLE);
} else {
mProgressBar.setVisibility(GONE);
}
mIconImageView = (ImageView) findViewById(R.id.rebound_listview_header_iv_icon);
if (headerIconSrc != null) {
mIconImageView.setVisibility(VISIBLE);
mIconImageView.setImageDrawable(headerIconSrc);
} else {
mIconImageView.setVisibility(GONE);
}
mRotateUpAnim = new RotateAnimation(0.0f, -180.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateUpAnim.setFillAfter(true);
mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
mRotateDownAnim.setFillAfter(true);
realHeaderHeight = DensityUtils.px2dip(context, 100);
}
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);
}
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
super(context);
mArrowImageView = new ImageView(context);
Drawable arrowD = getResources().getDrawable(R.mipmap.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);
}
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);
}
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);
}