下面列出了android.view.animation.ScaleAnimation#setRepeatMode() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* ���Ŷ���
*
* @param v
*/
public void scale(View v) {
/*
* ����1��x������ʼ��С(1f��ʾԭͼ��С) ����2��x������ֹ��С(0.2f��ʾԭͼ��0.2��)
* ����3��y������ʼ��С(1f��ʾԭͼ��С) ����4��y������ֹ��С(0.2f��ʾԭͼ��0.2��) ����5���������ĵ�x��ȡֵ�IJ��շ�ʽ
* ����6: ���ĵ�x���ȡֵ(0.5f��ʾ�����ԭͼ��0.5��) ����7���������ĵ�y��ȡֵ���շ�ʽ ����8:
* ���ĵ�y���ȡֵ(0.5f��ʾ�����ԭͼ��0.5��)
*/
ScaleAnimation rotate = new ScaleAnimation(4f, 0.2f, 4f, 0.2f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
// ������ʾʱ�䳤��
rotate.setDuration(2000);
// �����ظ�����
rotate.setRepeatCount(2);
// ���ö����ظ���ģʽ
rotate.setRepeatMode(Animation.REVERSE);
// ��ImageView�ϲ��Ŷ���
iv.startAnimation(rotate);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
private Animation getScaleAnimation() {
ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 2f,
1f, 2f,
getWidth() / 2, getHeight() / 2);
scaleAnimation.setDuration(2000);
scaleAnimation.setRepeatCount(2);
scaleAnimation.setFillAfter(true);
scaleAnimation.setFillBefore(false);
scaleAnimation.setRepeatMode(Animation.REVERSE);
return scaleAnimation;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
/**
格子触摸时的动画
*/
public Animation getItemTouchAnimation() {
ScaleAnimation scaleAnimation = new ScaleAnimation(1, .7F, 1, .7F, Animation.RELATIVE_TO_SELF, .5F, Animation.RELATIVE_TO_SELF, .5F);
scaleAnimation.setDuration(130);
scaleAnimation.setRepeatCount(1);
scaleAnimation.setRepeatMode(Animation.REVERSE);
return scaleAnimation;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
public static void ScaleUpDowm(View view) {
ScaleAnimation animation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
animation.setInterpolator(new LinearInterpolator());
animation.setDuration(1200);
view.startAnimation(animation);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
private Animation getScaleAnimation() {
ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 2f,
1f, 2f,
getWidth() / 2, getHeight() / 2);
scaleAnimation.setDuration(2000);
scaleAnimation.setRepeatCount(2);
scaleAnimation.setFillAfter(true);
scaleAnimation.setFillBefore(false);
scaleAnimation.setRepeatMode(Animation.REVERSE);
return scaleAnimation;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
/**
* Animates the layout when clicked. The animation used depends on whether the
* device is round or rectangular.
*/
public void onLayoutClicked(View view) {
if (mRectBackground != null) {
ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.7f, 1.0f, 0.7f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(300);
scaleAnimation.setRepeatCount(1);
scaleAnimation.setRepeatMode(Animation.REVERSE);
mRectBackground.startAnimation(scaleAnimation);
}
if (mRoundBackground != null) {
mRoundBackground.animate().rotationBy(360).setDuration(300).start();
}
}
private void animateOnTheEdge() {
if (!adapter.disableZoomAnimationsOnChangePage()) {
View v = getDraggedView();
ScaleAnimation scale = new ScaleAnimation(.667f, 1.5f, .667f, 1.5f, v.getMeasuredWidth() * 3 / 4, v.getMeasuredHeight() * 3 / 4);
scale.setDuration(200);
scale.setRepeatMode(Animation.REVERSE);
scale.setRepeatCount(Animation.INFINITE);
v.clearAnimation();
v.startAnimation(scale);
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
/**
* Animates the layout when clicked. The animation used depends on whether the
* device is round or rectangular.
*/
public void onLayoutClicked(View view) {
if (mRectBackground != null) {
ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.7f, 1.0f, 0.7f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(300);
scaleAnimation.setRepeatCount(1);
scaleAnimation.setRepeatMode(Animation.REVERSE);
mRectBackground.startAnimation(scaleAnimation);
}
if (mRoundBackground != null) {
mRoundBackground.animate().rotationBy(360).setDuration(300).start();
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
WIDTH = w;
HEIGHT = h;
scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2);
scaleAnimation.setDuration(zoomDuration);
scaleAnimation.setRepeatMode(Animation.REVERSE);
scaleAnimation.setRepeatCount(1);
}
public void mahang (View view){
AnimationSet set = new AnimationSet(false);
TranslateAnimation tras = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2);
// ������ʾʱ�䳤��
tras.setDuration(2000);
// �����ظ�����
tras.setRepeatCount(2);
// ���ö����ظ���ģʽ
tras.setRepeatMode(Animation.REVERSE);
RotateAnimation rotate = new RotateAnimation(360, 0,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
// ������ʾʱ�䳤��
rotate.setDuration(2000);
// �����ظ�����
rotate.setRepeatCount(2);
// ���ö����ظ���ģʽ
rotate.setRepeatMode(Animation.REVERSE);
ScaleAnimation scale = new ScaleAnimation(4f, 0.2f, 4f, 0.2f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
// ������ʾʱ�䳤��
scale.setDuration(2000);
// �����ظ�����
scale.setRepeatCount(2);
// ���ö����ظ���ģʽ
scale.setRepeatMode(Animation.REVERSE);
Animation alpha = new AlphaAnimation(1f, 0.1f);
// ������ʾʱ�䳤��
alpha.setDuration(2000);
// �����ظ�����
alpha.setRepeatCount(2);
// ���ö����ظ���ģʽ
alpha.setRepeatMode(Animation.REVERSE);
set.addAnimation(tras);
set.addAnimation(alpha);
set.addAnimation(rotate);
set.addAnimation(scale);
// ��ImageView�ϲ��Ŷ���
iv.startAnimation(set);
}
public void mahang (View view){
AnimationSet set = new AnimationSet(false);
TranslateAnimation tras = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2);
// ������ʾʱ�䳤��
tras.setDuration(2000);
// �����ظ�����
tras.setRepeatCount(2);
// ���ö����ظ���ģʽ
tras.setRepeatMode(Animation.REVERSE);
RotateAnimation rotate = new RotateAnimation(360, 0,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
// ������ʾʱ�䳤��
rotate.setDuration(2000);
// �����ظ�����
rotate.setRepeatCount(2);
// ���ö����ظ���ģʽ
rotate.setRepeatMode(Animation.REVERSE);
ScaleAnimation scale = new ScaleAnimation(4f, 0.2f, 4f, 0.2f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
// ������ʾʱ�䳤��
scale.setDuration(2000);
// �����ظ�����
scale.setRepeatCount(2);
// ���ö����ظ���ģʽ
scale.setRepeatMode(Animation.REVERSE);
Animation alpha = new AlphaAnimation(1f, 0.1f);
// ������ʾʱ�䳤��
alpha.setDuration(2000);
// �����ظ�����
alpha.setRepeatCount(2);
// ���ö����ظ���ģʽ
alpha.setRepeatMode(Animation.REVERSE);
set.addAnimation(tras);
set.addAnimation(alpha);
set.addAnimation(rotate);
set.addAnimation(scale);
// ��ImageView�ϲ��Ŷ���
iv.startAnimation(set);
}