android.view.animation.TranslateAnimation#setRepeatCount()源码实例Demo

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

源代码1 项目: imsdk-android   文件: CustomCaptureActvity.java
private void initCamera()
{
    autoFocusHandler = new Handler();
    mCameraManager = new CameraManager(this);
    try {
        mCameraManager.openDriver();
    } catch (Exception e) {
        LogUtil.e(TAG,"ERROR",e);
        finish();
    }

    mCamera = mCameraManager.getCamera();
    mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
    scanPreview.addView(mPreview);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.85f);
    animation.setDuration(3000);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.REVERSE);
    scanLine.startAnimation(animation);
}
 
源代码2 项目: ScanZbar   文件: CaptureActivity.java
private void initView() {
    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);
    findViewById(R.id.capture_imageview_back).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    isHasSurface = false;
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(3000);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);

}
 
源代码3 项目: Android   文件: ScanLoginActivity.java
@Override
public void initView() {
    mActivity = this;
    setViewFind(capturePreview, captureCropView, captureContainer);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
    animation.setDuration(1500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    captureScanLine.startAnimation(animation);
    //setLineAnimation(captureScanLine);

    setPresenter(new ScanLoginPresenter(this));
    presenter.start();
}
 
源代码4 项目: myapplication   文件: CaptureActivity.java
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);

    initButton();
}
 
源代码5 项目: AirFree-Client   文件: CaptureActivity.java
@Override
public void onCreate(Bundle icicle) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
}
 
/**
 * 为话题提示VIew绑定动画</br>
 */
private void startAnimationForTopicTipView() {
    int timePiece = 500;
    int repeatCount = 4;
    int startDeny = 50;
    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 10, 0);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    // translateAnimation.setStartOffset(startDeny * repeatCount+timePiece);
    translateAnimation.setRepeatCount(Integer.MAX_VALUE);
    translateAnimation.setDuration(timePiece);

    AlphaAnimation alphaAnimationIn = new AlphaAnimation(0, 1.0f);
    alphaAnimationIn.setDuration(timePiece);
    alphaAnimationIn.setStartOffset(startDeny * repeatCount);

    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(alphaAnimationIn);
    animationSet.addAnimation(translateAnimation);
    // animationSet.addAnimation(alphaAnimationOut);
    // animationSet.setFillAfter(true);
    mTopicTipView.startAnimation(animationSet);
}
 
源代码7 项目: ZXingProject   文件: CaptureActivity.java
@Override
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);

	Window window = getWindow();
	window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	setContentView(R.layout.activity_capture);

	scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
	scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
	scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
	scanLine = (ImageView) findViewById(R.id.capture_scan_line);

	inactivityTimer = new InactivityTimer(this);
	beepManager = new BeepManager(this);

	TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
			0.9f);
	animation.setDuration(4500);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.RESTART);
	scanLine.startAnimation(animation);
}
 
源代码8 项目: Android-Basics-Codes   文件: MainActivity.java
public void translate(View v){
		//����ƽ�Ʋ��䶯��
//		TranslateAnimation ta = new TranslateAnimation(-100, 100, -50, 50);
		
		ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -3, Animation.RELATIVE_TO_SELF, 3, 
				Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
		//���ö�������ʱ��
		ta.setDuration(2000);
		//�����ظ����Ŵ���
		ta.setRepeatCount(1);
		//�����ظ�����ģʽ
		ta.setRepeatMode(Animation.REVERSE);
		//���ö���ͣ���ڽ���λ��
		ta.setFillAfter(true);
		
		iv.startAnimation(ta);
	}
 
源代码9 项目: Android-Basics-Codes   文件: MainActivity.java
/**
 * λ�ƶ���
 * 
 * @param v
 */
public void translate(View v) {

	/*
	 * ����1,����3������5������7�� ���ò��յ�ķ�ʽ������Լ���Animation.RELATIVE_TO_SELF
	 * ����2��x����ʼ�ƶ���λ�� (0��ʾԭͼλ�����Ͻ�x�������) ����4��x��ֹͣ�ƶ���λ�ã�2��ʾ�ƶ�ԭͼ��ȵ�������
	 * ����6��y����ʼ�ƶ���λ�� (0��ʾԭͼλ�����Ͻ�y�������) ����8��y��ֹͣ�ƶ���λ�ã�2��ʾ�ƶ�ԭͼ�߶ȵ�������
	 */
	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);

	// ��ImageView�ϲ��Ŷ���
	iv.startAnimation(tras);
}
 
源代码10 项目: mollyim-android   文件: PassphrasePromptActivity.java
private void showFailure() {
  if (passphraseInput.requestFocus()) {
    InputMethodManager imm = ServiceUtil.getInputMethodManager(this);
    imm.showSoftInput(passphraseInput, InputMethodManager.SHOW_IMPLICIT);
  }

  TranslateAnimation shake = new TranslateAnimation(0, 30, 0, 0);
  shake.setDuration(50);
  shake.setRepeatCount(7);
  passphraseAuthContainer.startAnimation(shake);
}
 
源代码11 项目: AndroidWallet   文件: CaptureActivity.java
/**
     * 开始扫码
     */
    @SuppressLint("NewApi")
    private void startScan() {
        inactivityTimer = new InactivityTimer(this);
        beepManager = new BeepManager(this);
//        扫描线动画2(补间动画)
        translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.9f);
        translateAnimation.setDuration(4500);
        translateAnimation.setRepeatCount(-1);
        translateAnimation.setRepeatMode(Animation.RESTART);
        scanLine.startAnimation(translateAnimation);

        if (isPause) {
            objectAnimator.resume();
            isPause = false;
        } else {
            objectAnimator.start();
        }

        // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't
        // want to open the camera driver and measure the screen size if we're going to show the help on
        // first launch. That led to bugs where the scanning rectangle was the wrong size and partially
        // off screen.
        cameraManager = new CameraManager(getApplication());
        handler = null;
        if (isHasSurface) {
            // The activity was paused but not stopped, so the surface still exists. Therefore
            // surfaceCreated() won't be called, so init the camera here.
            initCamera(scanPreview.getHolder());
        } else {
            // Install the callback and wait for surfaceCreated() to init the camera.
            scanPreview.getHolder().addCallback(this);
        }
        inactivityTimer.onResume();
    }
 
源代码12 项目: SchoolQuest   文件: MiniGame.java
void setUpTextBoxArrowAnimation(ImageView textboxArrow) {
    TranslateAnimation textBoxArrowAnimation = new TranslateAnimation(
            TranslateAnimation.ABSOLUTE, 0f,
            TranslateAnimation.ABSOLUTE, 0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.01f);
    textBoxArrowAnimation.setDuration(500);
    textBoxArrowAnimation.setRepeatCount(-1);
    textBoxArrowAnimation.setRepeatMode(Animation.RESTART);
    textBoxArrowAnimation.setInterpolator(new LinearInterpolator());
    textBoxArrowAnimation.setFillAfter(true);

    textboxArrow.setAnimation(textBoxArrowAnimation);
}
 
源代码13 项目: SchoolQuest   文件: GameActivity.java
private void setUpTextBoxArrowAnimation() {
    ImageView textBoxArrow = findViewById(R.id.textbox_box_arrow);
    TranslateAnimation textBoxArrowAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f,
            TranslateAnimation.ABSOLUTE, 0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.01f);
    textBoxArrowAnimation.setDuration(500);
    textBoxArrowAnimation.setRepeatCount(-1);
    textBoxArrowAnimation.setRepeatMode(Animation.RESTART);
    textBoxArrowAnimation.setInterpolator(new LinearInterpolator());
    textBoxArrowAnimation.setFillAfter(true);

    textBoxArrow.setAnimation(textBoxArrowAnimation);
}
 
private Animation getTranslateAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(0, getWidth() * 2,
            0, getHeight() * 2);
    translateAnimation.setDuration(2000);
    translateAnimation.setRepeatCount(2);
    translateAnimation.setFillAfter(true);
    translateAnimation.setFillBefore(false);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    return translateAnimation;
}
 
private Animation getTranslateAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(0, getWidth() * 2,
            0, getHeight() * 2);
    translateAnimation.setDuration(2000);
    translateAnimation.setRepeatCount(2);
    translateAnimation.setFillAfter(true);
    translateAnimation.setFillBefore(false);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    return translateAnimation;
}
 
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	Window window = getWindow();
	window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	setContentView(R.layout.activity_capture);

	scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
	scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
	scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
	scanLine = (ImageView) findViewById(R.id.capture_scan_line);

	inactivityTimer = new InactivityTimer(this);

	TranslateAnimation animation = new TranslateAnimation(
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, -1.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f);
	animation.setDuration(4500);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.RESTART);
	scanLine.startAnimation(animation);

	btnCancel = (Button) findViewById(R.id.btn_cancel);
	ivReturn = (ImageView) findViewById(R.id.iv_return);
	OnClickListener myClick = new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			CaptureActivity.this.finish();
		}
	};
	btnCancel.setOnClickListener(myClick);
	ivReturn.setOnClickListener(myClick);
}
 
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	/**
	 * 设置为竖屏
	 */
	if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	}

	Window window = getWindow();
	window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	setContentView(R.layout.activity_gos_capture);

	scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
	scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
	scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
	scanLine = (ImageView) findViewById(R.id.capture_scan_line);

	inactivityTimer = new InactivityTimer(this);

	TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT,
			0.0f);
	animation.setDuration(4500);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.RESTART);
	scanLine.startAnimation(animation);

	btnCancel = (Button) findViewById(R.id.btn_cancel);
	ivReturn = (ImageView) findViewById(R.id.iv_return);
	OnClickListener myClick = new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			CaptureActivity.this.finish();
		}
	};
	btnCancel.setOnClickListener(myClick);
	ivReturn.setOnClickListener(myClick);
}
 
源代码18 项目: FamilyChat   文件: QrCodeScanActivity.java
protected void initUI()
{
    //全屏设置
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    {
        View statusBar = findViewById(R.id.view_qrcode_actionbar_status);
        statusBar.setVisibility(View.VISIBLE);
        ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams();
        layoutParams.height = OtherUtils.getStatusBarHeight(this);
        statusBar.setLayoutParams(layoutParams);
    }

    //闪光灯
    mImgLight = (ImageView) findViewById(R.id.img_qrcode_light);

    mScanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    mScanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    mScanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    mScanLine = (ImageView) findViewById(R.id.capture_scan_line);
    //设置阴影
    View shadowTop = findViewById(R.id.capture_mask_top);
    View shadowBottom = findViewById(R.id.capture_mask_bottom);
    View shadowLeft = findViewById(R.id.capture_mask_left);
    View shadowRight = findViewById(R.id.capture_mask_right);
    shadowTop.setAlpha(0.5f);
    shadowBottom.setAlpha(0.5f);
    shadowLeft.setAlpha(0.5f);
    shadowRight.setAlpha(0.5f);

    mInactivityTimer = new InactivityTimer(this);
    mBeepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.85f);
    animation.setDuration(2500);
    animation.setRepeatCount(-1);
    animation.setInterpolator(new AccelerateDecelerateInterpolator(QrCodeScanActivity.this, null));
    animation.setRepeatMode(Animation.RESTART);
    mScanLine.startAnimation(animation);

    findViewById(R.id.ll_qrcode_actionbar_left_back).setOnClickListener(this);
    mImgLight.setOnClickListener(this);
}
 
源代码19 项目: Android-Basics-Codes   文件: MainActivity.java
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);

}
 
源代码20 项目: Android-Basics-Codes   文件: MainActivity.java
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);

}